Plugin Directory

Changeset 610404


Ignore:
Timestamp:
10/10/2012 04:00:02 PM (13 years ago)
Author:
codebycarter
Message:
 
Location:
wp-bulletin-board/tags/1.0.3/php
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-categories.php

    r607181 r610404  
    1818if (isset($_POST['submit'])) {
    1919   
    20     if(!empty($_POST['wpbbcategoryname']) || !empty($_POST['wpbbcategoryorder'])) {
    21        
    22         $category_name = wp_strip_all_tags($_POST['wpbbcategoryname']);
    23        
    24         $order = absint($_POST['wpbbcategoryorder']);
    25 
    26         $data = array(
    27             'name' => $category_name,
    28             'forum' => 0,
    29             'subforum' => 0,
    30             'view' => '',
    31             'read' => '',
    32             'post' => '',
    33             'reply' => '',
    34             'edit' => '',
    35             'lock' => '',
    36             'delete' => '',
    37             'sticky' => '',
    38             'order' => $order
    39         );
     20    if(empty($_POST['wpbbcategoryname'])) {
     21        ?>
     22        <div id='message' class='error'>
     23            <?php
     24            _e('You must enter a category name!', 'wp-bb');
     25            exit();
     26            ?>
     27        </div>
     28        <?php
    4029    }
     30       
     31    $category_name = wp_strip_all_tags($_POST['wpbbcategoryname']);
     32       
     33    $order = absint($_POST['wpbbcategoryorder']);
     34
     35    $data = array(
     36        'name' => $category_name,
     37        'forum' => 0,
     38        'subforum' => 0,
     39        'view' => '',
     40        'read' => '',
     41        'post' => '',
     42        'reply' => '',
     43        'edit' => '',
     44        'lock' => '',
     45        'delete' => '',
     46        'sticky' => '',
     47        'order' => $order
     48    );
     49   
    4150   
    4251    $create_category = $wpdb->insert(CATEGORY_TABLE, $data);
    4352       
    4453    if ($create_category === false) {
    45            
    46         echo "<div id='message' class='error'>".__('Error creating category, please try again!', 'wp-bb')."</div>";
    47        
     54        ?>
     55        <div id='message' class='error'>
     56            <?php _e('Error creating category, please try again!', 'wp-bb'); ?>
     57        </div>
     58        <?php
    4859    } else {
    49            
    50         echo "<div id='message' class='updated'>".__('Category created successfully', 'wp-bb')."</div>";
    51    
     60        ?>
     61        <div id='message' class='updated'>
     62            <?php _e('Category created successfully', 'wp-bb'); ?>
     63        </div>
     64        <?php
    5265    }
    53    
    5466}
    5567
     
    196208    if ($_POST['wpbb-confirm-delete'] == 'yes') {
    197209       
    198         $id = absint($_POST['wpbb-confirm-delete-id']);
    199        
    200         $delete = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $id;");
     210        $category_id = absint($_POST['wpbb-confirm-delete-id']);
     211       
     212        $category_forums = $wpdb->get_results("SELECT id FROM ".CATEGORY_TABLE." WHERE forum = $category_id;");
     213       
     214        if ($category_forums) {
     215            foreach ($category_forums as $forum) {
     216                $forum_topics = $wpdb->get_results("SELECT id FROM ".TOPICS_TABLE." WHERE forum = $forum_id;");
     217                if ($forum_topics) {
     218                    foreach ($forum_topics as $topic) {
     219                        $topics_posts = $wpdb->get_results("SELECT id FROM ".POSTS_TABLE." WHERE topic = $topic->id;");
     220                        if ($topics_posts) {
     221                            foreach ($topics_posts as $post) {
     222                                $delete_post = $wpdb->query("DELETE FROM ".POSTS_TABLE." WHERE id = $post->id;");
     223                            }
     224                        }
     225                        $delete_topic = $wpdb->query("DELETE FROM ".TOPICS_TABLE." WHERE id = $topic->id;");
     226                    }
     227                }
     228                $forums_subforums = $wpdb->get_results("SELECT id FROM ".CATEGORY_TABLE." WHERE subforum = $forum->id;");
     229                if ($forums_subforums) {
     230                    foreach ($forums_subforums as $subforum) {
     231                        $subforum_topics = $wpdb->get_results("SELECT id FROM ".TOPICS_TABLE." WHERE subforum = $subforum->id;");
     232                        if ($subforum_topics) {
     233                            foreach ($subforum_topics as $topic) {
     234                                $topics_posts = $wpdb->get_results("SELECT id FROM ".POSTS_TABLE." WHERE topic = $topic->id;");
     235                                if ($topics_posts) {
     236                                    foreach ($topics_posts as $post) {
     237                                        $delete_post = $wpdb->query("DELETE FROM ".POSTS_TABLE." WHERE id = $post->id;");
     238                                    }
     239                                }
     240                                $delete_topic = $wpdb->query("DELETE FROM ".TOPICS_TABLE." WHERE id = $topic->id;");
     241                            }
     242                        }   
     243                    }
     244                    $delete_subforum = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $subforum->id;");
     245                }
     246                $delete_forum = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $forum->id;");
     247            }
     248        }
     249               
     250        $delete = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $category_id;");
    201251       
    202252        if ($delete === false) {
    203253            ?>
    204254            <div id='message' class='error'>
    205                 <?php printf(__('There was an error deleting Category ID %d, please try again.', 'wp-bb'), $id); ?>
     255                <?php printf(__('There was an error deleting Category ID %d, please try again.', 'wp-bb'),$category_id); ?>
    206256            </div>
    207257            <?php
     
    209259            ?>
    210260            <div id='message' class='updated'>
    211                 <?php printf(__('Category ID %d deleted successfully.', 'wp-bb'), $id); ?>
     261                <?php printf(__('Category ID %d deleted successfully.', 'wp-bb'), $category_id); ?>
    212262            </div>
    213263            <?php
     
    231281    <h3><?php _e('Confirm Delete Request', 'wp-bb'); ?></h3>
    232282
    233     <?php printf(__('Are you sure you want to delete Category ID %d?', 'wp-bb'), $id); ?>
     283    <?php printf(__('Are you sure you want to delete Category ID %d? WARNING: This will delete all forums and subforums along with any topics and posts contained within them.', 'wp-bb'), $id); ?>
    234284   
    235285    <form method='POST' action='#'>
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-forums.php

    r603518 r610404  
    208208                        if ($roles) {
    209209                            foreach ($roles as $role) {
    210                                 echo "<tr>";
    211                                 echo "<td>".$role."</td>";
    212                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."view' type='checkbox' value='wpbbadvancedpermissionstable".$role."view' /></td>";
    213                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."read' type='checkbox' value='wpbbadvancedpermissionstable".$role."read' /></td>";
    214                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."post' type='checkbox' value='wpbbadvancedpermissionstable".$role."post' /></td>";
    215                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."reply' type='checkbox' value='wpbbadvancedpermissionstable".$role."reply'/></td>";
    216                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."edit' type='checkbox' value='wpbbadvancedpermissionstable".$role."edit' /></td>";
    217                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."lock'  type='checkbox' value='wpbbadvancedpermissionstable".$role."lock' /></td>";
    218                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."sticky' type='checkbox' value='wpbbadvancedpermissionstable".$role."sticky' /></td>";
    219                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."delete' type='checkbox' value='wpbbadvancedpermissionstable".$role."delete' /></td>";
    220                                 echo "</tr>";
     210                                ?>
     211                                <tr>
     212                                <td>
     213                                    <?php
     214                                    if ($role == 'guest') {
     215                                        ?>
     216                                        <strong><?php _e('Guest', 'wp-bb'); ?></strong>
     217                                        <?php
     218                                    } else {
     219                                        echo ucfirst($role);
     220                                    }
     221                                    ?>
     222                                </td>
     223                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>view' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>view' /></td>
     224                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>read' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>read' /></td>
     225                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>post' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>post' /></td>
     226                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>reply' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>reply'/></td>
     227                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>edit' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>edit' /></td>
     228                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>lock'  type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>lock' /></td>
     229                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>sticky' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>sticky' /></td>
     230                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>delete' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>delete' /></td>
     231                                </tr>
     232                                <?php
    221233                            }
    222234                        }
     
    469481                                    break;
    470482                                }
    471                                 echo "<tr>";
    472                                 echo "<td>".$role."</td>";
    473                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."view' type='checkbox' value='wpbbadvancedpermissionstable".$role."view' ".$view_checked." /></td>";
    474                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."read' type='checkbox' value='wpbbadvancedpermissionstable".$role."read' ".$read_checked." /></td>";
    475                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."post' type='checkbox' value='wpbbadvancedpermissionstable".$role."post' ".$post_checked." /></td>";
    476                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."reply' type='checkbox' value='wpbbadvancedpermissionstable".$role."reply' ".$reply_checked." /></td>";
    477                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."edit' type='checkbox' value='wpbbadvancedpermissionstable".$role."edit' ".$edit_checked." /></td>";
    478                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."lock'  type='checkbox' value='wpbbadvancedpermissionstable".$role."lock' ".$lock_checked." /></td>";
    479                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."sticky' type='checkbox' value='wpbbadvancedpermissionstable".$role."sticky' ".$sticky_checked." /></td>";
    480                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."delete' type='checkbox' value='wpbbadvancedpermissionstable".$role."delete' ".$delete_checked." /></td>";
    481                                 echo "</tr>";
     483                                ?>
     484                                <tr>
     485                                    <td>
     486                                        <?php
     487                                            if ($role == 'guest') {
     488                                                ?>
     489                                                <strong><?php _e('Guest', 'wp-bb'); ?></strong>
     490                                                <?php
     491                                            } else {
     492                                                echo ucfirst($role);
     493                                            }
     494                                        ?>
     495                                    </td>
     496                                    <td>
     497                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>view' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>view' <?php echo $view_checked; ?> />
     498                                    </td>
     499                                    <td>
     500                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>read' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>read' <?php echo $read_checked; ?> />
     501                                    </td>
     502                                    <td>
     503                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>post' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>post' <?php echo $post_checked; ?> />
     504                                    </td>
     505                                    <td>
     506                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>reply' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>reply' <?php echo $reply_checked; ?> />
     507                                    </td>
     508                                    <td>
     509                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>edit' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>edit' <?php echo $edit_checked; ?> />
     510                                    </td>
     511                                    <td>
     512                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>lock'  type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>lock' <?php echo $lock_checked; ?> />
     513                                    </td>
     514                                    <td>
     515                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>sticky' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>sticky' <?php echo $sticky_checked; ?> />
     516                                    </td>
     517                                    <td>
     518                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>delete' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>delete' <?php echo $delete_checked; ?> />
     519                                    </td>
     520                                </tr>
     521                                <?php
    482522                            }
    483523                        }
     
    504544}
    505545   
     546/*
     547    Deleting a Forum (After Confirmation)
     548*/
     549
     550if (isset($_POST['wpbb-confirm-delete-submit'])) {
     551   
     552    if ($_POST['wpbb-confirm-delete'] == 'yes') {
     553       
     554        $forum_id = absint($_POST['wpbb-confirm-delete-id']);
     555       
     556        $forum_exists = $wpdb->get_var("SELECT id FROM ".CATEGORY_TABLE." WHERE id = $forum_id;");
     557       
     558        if ($forum_exists === NULL) {
     559            ?>
     560            <div id="message" class="error">
     561            <?php
     562            printf(__('Forum ID %s does not exist.'), $forum_id);
     563            ?>
     564            </div>
     565            <?php
     566            exit();
     567        }
     568       
     569        $forum_topics = $wpdb->get_results("SELECT id FROM ".TOPICS_TABLE." WHERE forum = $forum_id;");
     570       
     571        if ($forum_topics) {
     572            foreach ($forum_topics as $topic) {
     573                $topics_posts = $wpdb->get_results("SELECT id FROM ".POSTS_TABLE." WHERE topic = $topic->id;");
     574                if ($topics_posts) {
     575                    foreach ($topics_posts as $post) {
     576                        $delete_post = $wpdb->query("DELETE FROM ".POSTS_TABLE." WHERE id = $post->id;");
     577                    }
     578                }
     579                $delete_topic = $wpdb->query("DELETE FROM ".TOPICS_TABLE." WHERE id = $topic->id;");
     580            }
     581        }
     582       
     583        $forums_subforums = $wpdb->get_results("SELECT id FROM ".CATEGORY_TABLE." WHERE subforum = $forum_id;");
     584       
     585        if ($forums_subforums) {
     586            foreach ($forums_subforums as $subforum) {
     587                $subforum_topics = $wpdb->get_results("SELECT id FROM ".TOPICS_TABLE." WHERE subforum = $subforum->id;");
     588                if ($subforum_topics) {
     589                    foreach ($subforum_topics as $topic) {
     590                        $topics_posts = $wpdb->get_results("SELECT id FROM ".POSTS_TABLE." WHERE topic = $topic->id;");
     591                        if ($topics_posts) {
     592                            foreach ($topics_posts as $post) {
     593                                $delete_post = $wpdb->query("DELETE FROM ".POSTS_TABLE." WHERE id = $post->id;");
     594                            }
     595                        }
     596                        $delete_topic = $wpdb->query("DELETE FROM ".TOPICS_TABLE." WHERE id = $topic->id;");
     597                    }
     598                }
     599            }
     600            $delete_subforum = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $subforum->id;");
     601        }
     602       
     603        $delete = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $forum_id;");
     604       
     605        if ($delete === false) {
     606            ?>
     607            <div id="message" class="error">
     608            <?php
     609            printf(__('There was an error deleting Forum ID %s. Please try again.'), $forum_id);
     610            ?>
     611            </div>
     612            <?php
     613        } else {
     614            ?>
     615            <div id="message" class="updated">
     616            <?php
     617            printf(__('Forum ID %s deleted successfully.'), $forum_id);
     618            ?>
     619            </div>
     620            <?php
     621        }
     622   
     623    } else if ($_POST['wpbb-confirm-delete'] == 'no') {
     624        ?>
     625        <div id="message" class="error">
     626        <?php
     627        printf(__('There was an error deleting Forum ID %s. Please try again.'), $forum_id);
     628        ?>
     629        </div>
     630        <?php
     631    }
     632}
    506633
    507634/*
     
    519646    <h3><?php _e('Delete Forum', 'wp-bb'); ?></h3>
    520647       
    521     <?php printf(__('Are you sure you want to delete Forum ID %s?'), $id); ?>
     648    <?php printf(__('Are you sure you want to delete Forum ID %s? WARNING: This will delete all subforums, topics and posts within the forum.'), $id); ?>
    522649       
    523650    <form method='POST' action='#'>
     
    538665}
    539666
    540 /*
    541     Deleting a Forum (After Confirmation)
    542 */
    543 
    544 if (isset($_POST['wpbb-confirm-delete-submit'])) {
    545    
    546     if ($_POST['wpbb-confirm-delete'] == 'yes') {
    547        
    548         $id = absint($_POST['wpbb-confirm-delete-id']);
    549        
    550         $delete = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $id;");
    551        
    552         if ($delete === false) {
    553        
    554             printf(__('There was an error deleting Forum ID %s. Please try again.'), $id);
    555        
    556         } else {
    557        
    558             printf(__('Forum ID %s deleted successfully.'), $id);
    559        
    560         }
    561    
    562     } else if ($_POST['wpbb-confirm-delete'] == 'no') {
    563        
    564         wp_redirect('admin.php?page=wpbb_admin');
    565    
    566         exit;
    567     }
    568 }
    569 
    570667?>
    571668</div>
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-functions.php

    r603518 r610404  
    129129function wpbb_admin_get_all_roles($return = 'array', $setup = NULL) {
    130130    $wp_roles = new WP_Roles();
     131    $options = get_option('wpbb_options');
     132    if (isset($options['allow_guests']) && $options['allow_guests'] == 'yes') {
     133        if (!$wp_roles->get_role('guest')) {
     134            $guest_role = $wp_roles->add_role('guest', 'Guest', false);
     135        }
     136    }
    131137    $roles = $wp_roles->get_names();
    132138    $_roles = array();
     
    248254}
    249255
     256/**
     257 * Simple function that prints an error message and then terminates the script
     258 *
     259 *
     260 * @since 1.0.3
     261 *
     262 * @param    string     $text       The error message to display
     263 *                     
     264 */
     265function wpbb_error($text) {
     266    ?>
     267    <div id="message" class="error">
     268        <?php printf(__('%s'), $text); ?>
     269    </div>
     270    <?php
     271}
     272
     273/**
     274 * Simple function that prints a success message and then terminates the script
     275 *
     276 *
     277 * @since 1.0.3
     278 *
     279 * @param    string     $text       The success message to display
     280 *                     
     281 */
     282function wpbb_success($text) {
     283    ?>
     284    <div id="message" class="updated">
     285        <?php printf(__('%s'), $text); ?>
     286    </div>
     287    <?php
     288}
     289
     290/**
     291 * Simple function that alters the table structure with a new set of roles
     292 *
     293 *
     294 * @since 1.0.3
     295 *
     296 * @param     bool  $msgs   True if you want to echo error/success messages
     297 * @return    bool          False if errors true otherwise
     298 *                     
     299 */
     300function wpbb_refresh_roles($msgs = false) {
     301    global $wpdb;
     302    $wp_roles = wpbb_admin_get_all_roles('string', true);
     303    $permissions = array('view', 'read', 'post', 'reply', 'edit', 'lock', 'delete', 'sticky');
     304    $errors = 0;
     305    foreach ($permissions as $permission) {
     306        $update_table_structure = $wpdb->query("ALTER TABLE ".CATEGORY_TABLE." MODIFY  `$permission` SET($wp_roles);");
     307        if ($update_table_structure === false) {
     308            $errors++;
     309        }
     310    }
     311    if ($msgs) {
     312        if ($errors) {
     313            wpbb_error('Failed to refresh roles, please try again or make sure you have made changes to the roles');
     314        } else {
     315            wpbb_success('Refreshed roles successfully.');
     316        }
     317    }
     318}
     319
    250320// This will possibly be implemented in v1.0.1
    251321
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-main.php

    r603518 r610404  
    201201        <a href="admin.php?page=wpbb_admin_subforums" class="add-new-h2"><?php _e('New Subforum', 'wp-bb'); ?></a>
    202202        <a href="admin.php?page=wpbb_admin_topics" class="add-new-h2"><?php _e('New Topic', 'wp-bb'); ?></a>
     203        <a href="admin.php?page=wpbb_admin_tools" class="add-new-h2"><?php _e('Tools', 'wp-bb'); ?></a>
    203204    </h2>
    204205    <?php
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-settings.php

    r607181 r610404  
    5555    // Update options in DB
    5656    $update_options = update_option('wpbb_options', $new_options);
    57     unset($options);
    5857   
    5958} else if (isset($_POST['wpbb-theme-settings-submit'])) {
     
    161160            <tr>
    162161                <th>
    163                     <label for="wpbballowguests"><?php _e('Allow Guests to View Forum', 'wp-bb'); ?></label>
     162                    <label for="wpbballowguests"><?php _e('Enable Guest Permissions', 'wp-bb'); ?></label>
    164163                </th>
    165164                <td>
     
    187186            </tr>
    188187            <?php
    189             if (!isset($options['topics_per_page'])) {
    190                 $topics_per_page = "20";
    191             } else {
    192                 $topics_per_page = $options['topics_per_page'];
    193             }
    194            
    195             if (!isset($options['posts_per_page'])) {
    196                 $posts_per_page = "20";
    197             } else {
    198                 $posts_per_page = $options['posts_per_page'];
    199             }
    200         ?>
    201         <tr>
    202             <th>
    203                 <label for="wpbbtopicsperpage"><?php _e('Topics per page', 'wp-bb'); ?></label>
    204             </th>
    205             <td>
    206                 <input type="number" name="wpbbtopicsperpage" value="<?php echo $topics_per_page; ?>" />
    207             </td>
    208         </tr>
    209         <tr>
    210             <th>
    211                 <label for="wpbbpostsperpage"><?php _e('Posts per page', 'wp-bb'); ?></label>
    212             </th>
    213             <td>
    214                 <input type="number" name="wpbbpostsperpage" value="<?php echo $posts_per_page; ?>" />
    215             </td>
    216         </tr>
    217         <?php
    218             if (!isset($options['topic_cutoff'])) {
    219                 $topic_cutoff_value = "15";
    220             } else {
    221                 $topic_cutoff_value = $options['topic_cutoff'];
    222             }
    223                
    224             if (!isset($options['post_cutoff'])) {
    225                 $post_cutoff_value = "15";
    226             } else {
    227                 $post_cutoff_value = $options['post_cutoff'];
    228             }
     188            $topics_per_page = (!isset($options['topics_per_page'])) ? 20 : $options['topics_per_page'];
     189            $posts_per_page = (!isset($options['posts_per_page'])) ? 20 : $options['posts_per_page'];
    229190            ?>
    230         <tr>
    231             <th>
    232                 <label for="wpbbtopiccutoff"><?php _e('Delay between Topic creations', 'wp-bb'); ?></label>
    233             </th>
    234             <td>
    235                 <input type="number" name="wpbbtopiccutoff" min="0" value="<?php echo $topic_cutoff_value; ?>" />
    236             </td>
    237         </tr>
    238         <tr>
    239             <th>
    240                 <label for="wpbpostcutoff"><?php _e('Delay between Post creations', 'wp-bb'); ?></label>
    241             </th>
    242             <td>
    243                 <input type="number" name="wpbbpostcutoff" min="0" value="<?php echo $post_cutoff_value; ?>" />
    244             </td>
    245         </tr>
    246         <tr>
    247             <th>
    248                 <label for="wpposttowpbb"><?php _e('Enable Posting to Forum', 'wp-bb'); ?></label>
    249             </th>
    250             <td>
    251                 <input type="radio" name="wpposttowpbb" value="yes" <?php checked($options['post_to_forum'], 'yes');?>/> <?php _e('Yes', 'wp-bb'); ?>
    252                 <input type="radio" name="wpposttowpbb" value="no" <?php checked($options['post_to_forum'], 'no');?>/> <?php _e('No', 'wp-bb'); ?>
    253             </td>
    254         </tr>
    255         <tr>
    256             <th>
    257                 <label for="wpbb-show-footer"><?php _e('Show Footer', 'wp-bb'); ?></label>
    258             </th>
    259             <td>
    260                 <input type="radio" name="wpbb-show-footer" value="yes" <?php if (isset($options['show_footer'])) checked($options['show_footer'], 'yes');?>/> <?php _e('Yes', 'wp-bb'); ?>
    261                 <input type="radio" name="wpbb-show-footer" value="no" <?php if (isset($options['show_footer'])) checked($options['show_footer'], 'no');?>/> <?php _e('No', 'wp-bb'); ?>
    262                 <p class="description">Displays a copyright message at the bottom of your forum. Disabled by default.</p>
    263             </td>
    264         </tr>
    265         <tr>
    266             <td>
    267                 <input type="submit" name="wpbb-settings-submit" class="button-primary" value="<?php _e('Save Changes', 'wp-bb'); ?>" />
    268             </td>
    269         </tr>
    270     </form>
     191            <tr>
     192                <th>
     193                    <label for="wpbbtopicsperpage"><?php _e('Topics per page', 'wp-bb'); ?></label>
     194                </th>
     195                <td>
     196                    <input type="number" name="wpbbtopicsperpage" value="<?php echo $topics_per_page; ?>" />
     197                </td>
     198            </tr>
     199            <tr>
     200                <th>
     201                    <label for="wpbbpostsperpage"><?php _e('Posts per page', 'wp-bb'); ?></label>
     202                </th>
     203                <td>
     204                    <input type="number" name="wpbbpostsperpage" value="<?php echo $posts_per_page; ?>" />
     205                </td>
     206            </tr>
     207            <?php
     208            $topic_cutoff_value = (!isset($options['topic_cutoff'])) ? 15 : $options['topic_cutoff'];
     209            $post_cutoff_value = (!isset($options['post_cutoff'])) ? 15 : $options['post_cutoff'];
     210            ?>
     211            <tr>
     212                <th>
     213                    <label for="wpbbtopiccutoff"><?php _e('Delay between Topic creations', 'wp-bb'); ?></label>
     214                </th>
     215                <td>
     216                    <input type="number" name="wpbbtopiccutoff" min="0" value="<?php echo $topic_cutoff_value; ?>" />
     217                </td>
     218            </tr>
     219            <tr>
     220                <th>
     221                    <label for="wpbpostcutoff"><?php _e('Delay between Post creations', 'wp-bb'); ?></label>
     222                </th>
     223                <td>
     224                    <input type="number" name="wpbbpostcutoff" min="0" value="<?php echo $post_cutoff_value; ?>" />
     225                </td>
     226            </tr>
     227            <tr>
     228                <th>
     229                    <label for="wpposttowpbb"><?php _e('Enable Posting to Forum', 'wp-bb'); ?></label>
     230                </th>
     231                <td>
     232                    <input type="radio" name="wpposttowpbb" value="yes" <?php checked($options['post_to_forum'], 'yes');?>/> <?php _e('Yes', 'wp-bb'); ?>
     233                    <input type="radio" name="wpposttowpbb" value="no" <?php checked($options['post_to_forum'], 'no');?>/> <?php _e('No', 'wp-bb'); ?>
     234                </td>
     235            </tr>
     236            <tr>
     237                <th>
     238                    <label for="wpbb-show-footer"><?php _e('Show Footer', 'wp-bb'); ?></label>
     239                </th>
     240                <td>
     241                    <input type="radio" name="wpbb-show-footer" value="yes" <?php if (isset($options['show_footer'])) checked($options['show_footer'], 'yes');?>/> <?php _e('Yes', 'wp-bb'); ?>
     242                    <input type="radio" name="wpbb-show-footer" value="no" <?php if (isset($options['show_footer'])) checked($options['show_footer'], 'no');?>/> <?php _e('No', 'wp-bb'); ?>
     243                    <p class="description">Displays a copyright message at the bottom of your forum. Disabled by default.</p>
     244                </td>
     245            </tr>
     246            <tr>
     247                <td>
     248                    <input type="submit" name="wpbb-settings-submit" class="button-primary" value="<?php _e('Save Changes', 'wp-bb'); ?>" />
     249                </td>
     250            </tr>
     251        </form>
    271252    </table>
    272253    <h3><?php _e('Theme Settings', 'wp-bb'); ?></h3>
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-subforums.php

    r603518 r610404  
    9696                        if ($roles) {
    9797                            foreach ($roles as $role) {
    98                                 echo "<tr>";
    99                                 echo "<td>".$role."</td>";
    100                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."view' type='checkbox' value='wpbbadvancedpermissionstable".$role."view' /></td>";
    101                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."read' type='checkbox' value='wpbbadvancedpermissionstable".$role."read' /></td>";
    102                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."post' type='checkbox' value='wpbbadvancedpermissionstable".$role."post' /></td>";
    103                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."reply' type='checkbox' value='wpbbadvancedpermissionstable".$role."reply'/></td>";
    104                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."edit' type='checkbox' value='wpbbadvancedpermissionstable".$role."edit' /></td>";
    105                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."lock'  type='checkbox' value='wpbbadvancedpermissionstable".$role."lock' /></td>";
    106                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."sticky' type='checkbox' value='wpbbadvancedpermissionstable".$role."sticky' /></td>";
    107                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."delete' type='checkbox' value='wpbbadvancedpermissionstable".$role."delete' /></td>";
    108                                 echo "</tr>";
     98                                ?>
     99                                <tr>
     100                                <td>
     101                                    <?php
     102                                    if ($role == 'guest') {
     103                                        ?>
     104                                        <strong><?php _e('Guest', 'wp-bb'); ?></strong>
     105                                        <?php
     106                                    } else {
     107                                        echo ucfirst($role);
     108                                    }
     109                                    ?>
     110                                </td>
     111                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>view' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>view' /></td>
     112                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>read' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>read' /></td>
     113                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>post' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>post' /></td>
     114                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>reply' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>reply'/></td>
     115                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>edit' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>edit' /></td>
     116                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>lock'  type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>lock' /></td>
     117                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>sticky' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>sticky' /></td>
     118                                <td><input name='wpbbadvancedpermissionstable<?php echo $role;?>delete' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role;?>delete' /></td>
     119                                </tr>
     120                                <?php
    109121                            }
    110122                        }
     
    291303                        <th><?php _e('Description', 'wp-bb'); ?></th>
    292304                        <td>
    293                             <?php wp_editor($type->description, 'wpbbsubforumdescription'); ?></td>
     305                            <?php wp_editor($type->description, 'wpbbsubforumdescription'); ?>
    294306                            <p class="description"><?php _e('The subforum description, shown below the subforum name on the forum index (max 200 characters)', 'wp-bb'); ?></p>
    295307                        </td>
     
    368380                                    break;
    369381                                }
    370                                 echo "<tr>";
    371                                 echo "<td>".$role."</td>";
    372                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."view' type='checkbox' value='wpbbadvancedpermissionstable".$role."view' ".$view_checked." /></td>";
    373                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."read' type='checkbox' value='wpbbadvancedpermissionstable".$role."read' ".$read_checked." /></td>";
    374                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."post' type='checkbox' value='wpbbadvancedpermissionstable".$role."post' ".$post_checked." /></td>";
    375                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."reply' type='checkbox' value='wpbbadvancedpermissionstable".$role."reply' ".$reply_checked." /></td>";
    376                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."edit' type='checkbox' value='wpbbadvancedpermissionstable".$role."edit' ".$edit_checked." /></td>";
    377                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."lock'  type='checkbox' value='wpbbadvancedpermissionstable".$role."lock' ".$lock_checked." /></td>";
    378                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."sticky' type='checkbox' value='wpbbadvancedpermissionstable".$role."sticky' ".$sticky_checked." /></td>";
    379                                 echo "<td><input name='wpbbadvancedpermissionstable".$role."delete' type='checkbox' value='wpbbadvancedpermissionstable".$role."delete' ".$delete_checked." /></td>";
    380                                 echo "</tr>";
     382                                ?>
     383                                <tr>
     384                                    <td>
     385                                        <?php
     386                                            if ($role == 'guest') {
     387                                                ?>
     388                                                <strong><?php _e('Guest', 'wp-bb'); ?></strong>
     389                                                <?php
     390                                            } else {
     391                                                echo ucfirst($role);
     392                                            }
     393                                        ?>
     394                                    </td>
     395                                    <td>
     396                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>view' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>view' <?php echo $view_checked; ?> />
     397                                    </td>
     398                                    <td>
     399                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>read' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>read' <?php echo $read_checked; ?> />
     400                                    </td>
     401                                    <td>
     402                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>post' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>post' <?php echo $post_checked; ?> />
     403                                    </td>
     404                                    <td>
     405                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>reply' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>reply' <?php echo $reply_checked; ?> />
     406                                    </td>
     407                                    <td>
     408                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>edit' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>edit' <?php echo $edit_checked; ?> />
     409                                    </td>
     410                                    <td>
     411                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>lock'  type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>lock' <?php echo $lock_checked; ?> />
     412                                    </td>
     413                                    <td>
     414                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>sticky' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>sticky' <?php echo $sticky_checked; ?> />
     415                                    </td>
     416                                    <td>
     417                                        <input name='wpbbadvancedpermissionstable<?php echo $role; ?>delete' type='checkbox' value='wpbbadvancedpermissionstable<?php echo $role; ?>delete' <?php echo $delete_checked; ?> />
     418                                    </td>
     419                                </tr>
     420                                <?php
    381421                            }
    382422                        }
     
    529569}
    530570
     571
     572/*
     573    Deleting a Subforum (After Confirmation)
     574*/
     575
     576if (isset($_POST['wpbb-confirm-delete-submit'])) {
     577   
     578    if ($_POST['wpbb-confirm-delete'] == 'yes') {
     579       
     580        $subforum_id = absint($_POST['wpbb-confirm-delete-id']);
     581       
     582        $subforum_exists = $wpdb->get_var("SELECT id FROM ".CATEGORY_TABLE." WHERE id = $subforum_id;");
     583       
     584        if ($subforum_exists === NULL) {
     585            ?>
     586            <div id="message" class="error">
     587            <?php
     588            printf(__('Subforum ID %s does not exist.'), $subforum_id);
     589            ?>
     590            </div>
     591            <?php
     592            exit();
     593        }
     594       
     595        $subforum_topics = $wpdb->get_results("SELECT id FROM ".TOPICS_TABLE." WHERE subforum = $subforum_id;");
     596       
     597        if ($subforum_topics) {
     598            foreach ($subforum_topics as $topic) {
     599                $topics_posts = $wpdb->get_results("SELECT id FROM ".POSTS_TABLE." WHERE topic = $topic->id;");
     600                if ($topics_posts) {
     601                    foreach ($topics_posts as $post) {
     602                        $delete_post = $wpdb->query("DELETE FROM ".POSTS_TABLE." WHERE id = $post->id;");
     603                    }
     604                }
     605                $delete_topic = $wpdb->query("DELETE FROM ".TOPICS_TABLE." WHERE id = $topic->id;");
     606            }
     607        }
     608               
     609        $delete = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $subforum_id;");
     610       
     611        if ($delete === false) {
     612            ?>
     613            <div id="message" class="error">
     614            <?php
     615                printf(__('There was an error deleting Subforum ID %s. Please try again'), $subforum_id);
     616            ?>
     617            </div>
     618            <?php
     619        } else {
     620            ?>
     621            <div id="message" class="updated">
     622            <?php
     623            printf(__('Subforum ID %s deleted successfully.'), $subforum_id);
     624            ?>
     625            </div>
     626            <?php
     627        }
     628   
     629    } else if ($_POST['wpbb-confirm-delete'] == 'no') {
     630       
     631        wp_redirect('admin.php?page=wpbb_admin');
     632   
     633        exit;
     634    }
     635}
     636
    531637/*
    532638    Confirming a Delete Subforum request
     
    543649    <h3><?php _e('Delete Subforum', 'wp-bb'); ?></h3>
    544650   
    545     <?php printf(__('Are you sure you want to delete Subforum ID %s'), $id); ?>
     651    <?php printf(__('Are you sure you want to delete Subforum ID %s? WARNING: This will delete all topics and posts within the subforum.'), $id); ?>
    546652       
    547653    <form method='POST' action='#'>
     
    562668}
    563669
    564 /*
    565     Deleting a Subforum (After Confirmation)
    566 */
    567 
    568 if (isset($_POST['wpbb-confirm-delete-submit'])) {
    569    
    570     if ($_POST['wpbb-confirm-delete'] == 'yes') {
    571        
    572         $id = absint($_POST['wpbb-confirm-delete-id']);
    573        
    574         $delete = $wpdb->query("DELETE FROM ".CATEGORY_TABLE." WHERE id = $id;");
    575        
    576         if ($delete === false) {
    577             ?>
    578             <div id='message' class='error'>
    579             <?php
    580                 printf(__('There was an error deleting Subforum ID %s. Please try again'), $id);
    581             ?>
    582             </div>
    583             <?php
    584         } else {
    585             ?>
    586             <div id='message' class='updated'>
    587             <?php
    588             printf(__('Subforum ID %s deleted successfully.'), $id);
    589             ?>
    590             </div>
    591             <?php
    592         }
    593    
    594     } else if ($_POST['wpbb-confirm-delete'] == 'no') {
    595        
    596         wp_redirect('admin.php?page=wpbb_admin');
    597    
    598         exit;
    599     }
    600 }
    601 
    602670?>
  • wp-bulletin-board/tags/1.0.3/php/admin/wpbb-admin-topics.php

    r603518 r610404  
    33global $wpdb;
    44
    5     // Process create new topic form
    6     if (isset($_POST['submit'])) {
    7         if(!empty($_POST['wpbbtopicname']) || !empty($_POST['wpbbtopiccontent'])) {
    8             global $wpdb;
     5
     6if (isset($_POST['submit'])) {
     7
     8    if (empty($_POST['wpbbtopicname'])) {
     9        wpbb_error("You must enter a topic name!");
     10    }
    911           
    10             $topic_name = wp_strip_all_tags($_POST['wpbbtopicname']);
     12    if (empty($_POST['wpbbtopiccontent'])) {
     13        wpbb_error("The topic content cannot be blank!");
     14    }
    1115           
    12             if (!empty($_POST['wpbbtopicauthorname'])) {
     16    if (empty($_POST['wpbbtopicforumname'])) {
     17        wpbb_error("You must select a forum or create a forum before creating a topic!");
     18    }
    1319           
    14                 if (is_numeric($_POST['wpbbtopicauthorname'])) { // ID
     20    global $wpdb;
    1521           
    16                 $author_id = absint($_POST['wpbbtopicauthorname']);
     22    $topic_name = wp_strip_all_tags($_POST['wpbbtopicname']);
     23           
     24    if (!empty($_POST['wpbbtopicauthorname'])) {
     25       
     26        if (is_numeric($_POST['wpbbtopicauthorname'])) { // ID
     27           
     28            $author_id = absint($_POST['wpbbtopicauthorname']);
    1729               
    18                 } else if (is_string($_POST['wpbbtopicauthorname'])) { // Name
    19                
    20                     $author_name = wp_strip_all_tags($_POST['wpbbtopicauthorname']);
    21                
    22                     $author_id = wpbb_admin_parse_author_name(NULL, $author_name);
    23                
    24                 }
     30        } else if (is_string($_POST['wpbbtopicauthorname'])) { // Name
    2531           
    26             } else {
     32            $author_name = wp_strip_all_tags($_POST['wpbbtopicauthorname']);
    2733           
    28                 $author_id = absint($_POST['wpbbtopicadminid']);
    29             }
     34            $author_id = wpbb_admin_parse_author_name(NULL, $author_name);
    3035           
    31             $topic_content = wpbb_admin_strip_tags($_POST['wpbbtopiccontent']);
     36        }
    3237           
    33             $forum_id = absint($_POST['wpbbtopicforumname']);
     38    } else {
     39       
     40        $author_id = absint($_POST['wpbbtopicadminid']);
     41    }
    3442           
    35             $forum_type = $wpdb->get_row("SELECT id,forum,subforum FROM ".CATEGORY_TABLE." WHERE id = $forum_id;");
     43    $topic_content = wpbb_admin_strip_tags($_POST['wpbbtopiccontent']);
    3644           
    37             if ($forum_type->forum > 0) {
    38                 $topic_forum = $forum_id;
    39                 $topic_subforum = 0;
    40             } else if ($forum_type->subforum > 0) {
    41                 $topic_subforum = $forum_id;
    42                 $topic_forum = 0;
    43             }
     45    $forum_id = absint($_POST['wpbbtopicforumname']);
     46       
     47    $forum_type = $wpdb->get_row("SELECT id,forum,subforum FROM ".CATEGORY_TABLE." WHERE id = $forum_id;");
     48       
     49    if ($forum_type->forum > 0) {
     50        $topic_forum = $forum_id;
     51        $topic_subforum = 0;
     52    } elseif ($forum_type->subforum > 0) {
     53        $topic_subforum = $forum_id;
     54        $topic_forum = 0;
     55    }
    4456           
     57    $date = $date = date("Y-m-d H:i:s");
     58   
     59    $status = (!empty($_POST['wpbbtopicstatus'])) ? implode(",", $_POST['wpbbtopicstatus']) : '';
    4560           
    46             $date = $date = date("Y-m-d H:i:s");
    47            
    48             if (!empty($_POST['wpbbtopicstatus'])) {
    49                 $status = implode(",", $_POST['wpbbtopicstatus']);
    50             } else {
    51                 $status = '';
    52             }
    53            
    54             $data = array(
    55                 'name' => $topic_name,
    56                 'author' => $author_id,
    57                 'content' => $topic_content,
    58                 'forum' => $topic_forum,
    59                 'subforum' => $topic_subforum,
    60                 'status' => $status,
    61                 'created' => $date,
    62                 'last_reply' => $date
    63             );
    64         }
    65         $create_topic = $wpdb->insert(TOPICS_TABLE, $data);
    66         if ($create_topic) {
    67             ?>
    68             <div id='message' class='updated'>
    69                 <?php
    70                 _e('Topic created successfully', 'wp-bb');
    71                 ?>
    72             </div>
    73             <?php
    74            
    75         } else  {
    76             ?>
    77             <div id='message' class='error'>
    78                 <?php
    79                 _e('Error creating new topic, please try again!', 'wp-bb');
    80                 ?>
    81             </div>
    82             <?php
    83         }
     61    $data = array(
     62        'name' => $topic_name,
     63        'author' => $author_id,
     64        'content' => $topic_content,
     65        'forum' => $topic_forum,
     66        'subforum' => $topic_subforum,
     67        'status' => $status,
     68        'created' => $date,
     69        'last_reply' => $date
     70    );
     71
     72    $create_topic = $wpdb->insert(TOPICS_TABLE, $data);
     73    if ($create_topic) {
     74        wpbb_success('Topic created successfully');
     75    } else {
     76        wpbb_error('Error creating new topic, please try again!');
    8477    }
    85     $admin_id = get_current_user_id();
    86     $admin_userdata = get_userdata($admin_id);
    87     ?>
    88     <div class="wrap">
    89     <form action="" method="POST" id="adminCreateTopic">
     78}
     79
     80
     81$admin_id = get_current_user_id();
     82$admin_userdata = get_userdata($admin_id);
     83?>
     84<div class="wrap">
     85<form action="" method="POST" id="adminCreateTopic">
    9086            <div id="icon-plugins" class="icon32"></div>
    9187            <h2><?php _e('Topics', 'wp-bb'); ?></h2>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-all-messages.php

    r607181 r610404  
    1515    </p>
    1616</a>
     17
    1718   
    1819<?php
    19 
    2020if ($user_id != 0) {
    2121    $options = get_option('wpbb_options');
     
    4040    if (($total_msgs > 0) && ($total_msgs > $topics_per_page)) {
    4141        wpbb_pagination(NULL, $current_page, $start, $limit, $total_msgs, $topics_per_page, true, 'messages');
    42         $msgs = $wpdb->get_results("SELECT * FROM ".MESSAGES_TABLE." WHERE `to` = $user_id ORDER BY sent DESC LIMIT $start, $limit;");
    4342    }
     43    $msgs = $wpdb->get_results("SELECT * FROM ".MESSAGES_TABLE." WHERE `to` = $user_id ORDER BY sent DESC LIMIT $start, $limit;");
    4444    if ($msgs) {
    4545        wpbb_goback1('all-messages', NULL);
  • wp-bulletin-board/tags/1.0.3/php/wpbb-create-topic.php

    r607181 r610404  
    6767    }
    6868   
    69     /*
    70         Check the topic cutoff delay has passed
    71     */
    72    
    73     // Get the options
     69    $user_roles = wpbb_user_permission($user_id);
     70       
    7471    $wpbb_options = get_option('wpbb_options');
    75    
    76     // Retrieve the delay between topics
    77     $topic_cutoff = $wpbb_options['topic_cutoff'];
    78    
    79     // Get the users last post
    80     $user_last_post = get_user_meta($user_id, 'wpbb_lastpost', true);
     72           
     73    // Retrieve the delay between posts
     74    $post_cutoff = $wpbb_options['post_cutoff'];
     75   
     76    if ($user_roles == 'guest') {
     77        $guest_options = get_option('wpbb_guest_options');
     78        $user_last_post = $guest_options['guest_last_post'];
     79    } else {
     80        // Get the users last post
     81        $user_last_post = get_user_meta($user_id, 'wpbb_lastpost', true);
     82    }
    8183   
    8284    // Get the current date as a formatted date string
    8385    $current_date = date('Y-m-d H:i:s');
    84    
    85     // Convert topic cutoff to seconds
     86           
     87    // Convert post cutoff to seconds
    8688    $user_last_post_secs = strtotime($user_last_post);
    87    
     89           
    8890    // Topic cutoff delay in seconds multiplied by the user last post in seconds will be the number of seconds
    8991    // in the future when that delay has passed
    90     $delay_passed_secs = $user_last_post_secs + $topic_cutoff;
    91    
     92    $delay_passed_secs = $user_last_post_secs + $post_cutoff;
     93           
    9294    // We then convert those seconds to a formatted date string using our seconds as the timestamp
    9395    $delay_passed_date = date('Y-m-d H:i:s', $delay_passed_secs);
     
    152154            </div>
    153155            <?php
    154             wpbb_update_user_meta($user_id, 'increase');
     156            if ($user_roles != 'guest') {
     157                wpbb_update_user_meta($user_id, 'increase');
     158            }
    155159            wpbb_update_user_lastpost($user_id);
    156160        }
     
    193197                </td>
    194198            </tr>
    195             <tr>
    196                 <th><?php _e('Status', 'wp-bb'); ?></th>
    197                 <td>
    198                     <input type="checkbox" name="wpbb-topic-status[]" value="locked"> <?php _e('Locked', 'wp-bb'); ?>
    199                     <input type="checkbox" name="wpbb-topic-status[]" value="sticky"> <?php _e('Sticky', 'wp-bb'); ?>
    200                 </td>
    201             </tr>
     199            <?php
     200            $lock_permissions = wpbb_user_has_permission($user_id, $forum_id, 'lock');
     201            $sticky_permissions = wpbb_user_has_permission($user_id, $forum_id, 'sticky');
     202            if ($lock_permissions || $sticky_permissions || current_user_can('manage_options')) {
     203                ?>
     204                <tr>
     205                    <th><?php _e('Status', 'wp-bb'); ?></th>
     206                    <td>
     207                    <?php
     208                    if ($lock_permissions || current_user_can('manage_options')) {
     209                        ?>
     210                        <input type="checkbox" name="wpbb-topic-status[]" value="locked"/> <?php _e('Locked', 'wp-bb');
     211                    }
     212                    if ($sticky_permissions || current_user_can('manage_options')) {
     213                        ?>
     214                        <input type="checkbox" name="wpbb-topic-status[]" value="sticky"/> <?php _e('Sticky', 'wp-bb');
     215                    }
     216                    ?>
     217                    </td>
     218                </tr>
     219                <?php
     220            }
     221            ?>
    202222            <tr>
    203223                <th></th>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-delete-topic.php

    r607181 r610404  
    5151                        <?php
    5252                        $success = true;
    53                         wpbb_update_user_meta($user_id, 'decrease');
    5453                    }
    5554           
     
    113112                    <?php
    114113                    $success = true;
    115                    
    116                     wpbb_update_user_meta($user_id, 'decrease');
    117                
    118114                } else { // Error
    119115           
  • wp-bulletin-board/tags/1.0.3/php/wpbb-edit-topic.php

    r607181 r610404  
    7070        // Sanitize topic title
    7171        $topic_name = wp_strip_all_tags($_POST['wpbbtopicname']);
    72            
    73         if (is_numeric($_POST['wpbbauthorname'])) { // ID supplied
    74             $topic_author = absint($_POST['wpbbauthorname']);
    75 
    76         } else if (is_string($_POST['wpbbauthorname'])) { // Name supplied
    77             $topic_author_name = wp_strip_all_tags($_POST['wpbbauthorname']);
    78             $topic_author = wpbb_parse_author_name(NULL, $topic_author_name);
     72       
     73        $topic_author_name = 'Guest';
     74        $topic_author = 0;
     75       
     76        if (isset($_POST['wpbbauthorname'])) {
     77            if (is_numeric($_POST['wpbbauthorname'])) { // ID supplied
     78                $topic_author = absint($_POST['wpbbauthorname']);
     79            } else if (is_string($_POST['wpbbauthorname'])) { // Name supplied
     80                $topic_author_name = wp_strip_all_tags($_POST['wpbbauthorname']);
     81                $topic_author = wpbb_parse_author_name(NULL, $topic_author_name);
     82            }
    7983        }
    8084       
     
    144148    }
    145149    // End Form Submission
    146     $get_topic = $wpdb->get_results("SELECT * FROM ".TOPIC_TABLE." WHERE id = $topic_id;");
    147     if ($get_topic !== false) {
     150    $topic = $wpdb->get_row("SELECT id, author, name, content, forum, subforum, status FROM ".TOPIC_TABLE." WHERE id = $topic_id;");
     151    if ($topic != NULL) {
    148152        ?>
    149153        <table class="wpbb-table">
    150154            <form method='POST' action='#'>
    151155                <?php
    152                 foreach ($get_topic as $topic) {
    153156                    $sticky = (strpos($topic->status, 'sticky') !== false) ? true : false;
    154157                    $locked = (strpos($topic->status, 'locked') !== false) ? true : false;
     
    165168                        ?>
    166169                        <tr>
    167                         <th><?php _e('Author', 'wp-bb'); ?></th>
    168                         <td>
    169                             <input name='wpbbauthorname' maxlength='45' size='25' value='<?php echo $topic_author_name; ?>' />
    170                         </td>
    171                     </tr>
    172                     <?php
    173                 } else {
     170                            <th><?php _e('Author', 'wp-bb'); ?></th>
     171                            <td>
     172                                <input name='wpbbauthorname' maxlength='45' size='25' value='<?php echo $topic_author_name; ?>' />
     173                            </td>
     174                        </tr>
     175                        <?php
     176                    } else {
     177                        ?>
     178                        <tr>
     179                            <th><?php _e('Author', 'wp-bb'); ?></th>
     180                            <td>
     181                                <input name='wpbbauthorname' maxlength='45' size='25' value='<?php echo $topic_author_name; ?>' disabled='disabled'/>
     182                            </td>
     183                        </tr>
     184                        <?php
     185                    }
     186                    $is_forum = ($topic->forum > 0) ? true: false;
     187                    $is_subforum = ($topic->subforum > 0) ? true : false;
     188                    // Forums
    174189                    ?>
    175190                    <tr>
    176                         <th><?php _e('Author', 'wp-bb'); ?></th>
     191                        <th><?php _e('Choose Forum', 'wp-bb'); ?></th>
    177192                        <td>
    178                             <input name='wpbbauthorname' maxlength='45' size='25' value='<?php echo $topic_author_name; ?>' disabled='disabled'/>
    179                         </td>
    180                     </tr>
    181                     <?php
    182                 }
    183                 $is_forum = ($topic->forum > 0) ? true: false;
    184                 $is_subforum = ($topic->subforum > 0) ? true : false;
    185                 // Forums
    186                 ?>
    187                 <tr>
    188                     <th><?php _e('Choose Forum', 'wp-bb'); ?></th>
    189                     <td>
    190                         <input type='radio' name='wpbbtopicforum' value='yes' <?php echo checked($is_forum, true, false); ?>/> <?php _e('Yes', 'wp-bb'); ?>
    191                         <input type='radio' name='wpbbtopicforum'  value='no' <?php echo checked($is_forum, false, false); ?> /> <?php _e('No', 'wp-bb'); ?>
    192                         <select name='wpbbtopicforumname'>
    193                         <?php
    194                         $forums = $wpdb->get_results("SELECT * FROM ".CATEGORY_TABLE." WHERE forum > 0 AND subforum = 0;");
    195                         if ($forums !== false) {
    196                             foreach ($forums as $forum) {
    197                                 ?>
    198                                 <option value='<?php echo $forum->id; ?>' <?php selected($forum->id, $topic->forum); ?>>
    199                                     <?php echo $forum->name; ?>
    200                                 </option>
     193                            <input type='radio' name='wpbbtopicforum' value='yes' <?php echo checked($is_forum, true, false); ?>/> <?php _e('Yes', 'wp-bb'); ?>
     194                            <input type='radio' name='wpbbtopicforum'  value='no' <?php echo checked($is_forum, false, false); ?> /> <?php _e('No', 'wp-bb'); ?>
     195                            <select name='wpbbtopicforumname'>
    201196                                <?php
    202                             }
    203                         } else {
    204                             ?>
    205                             <div class="wpbb-message-failure">
    206                                 <?php _e('There are no forums', 'wp-bb'); ?>
    207                             </div>
    208                             <?php
    209                             wpbb_exit();
    210                         }
     197                                $forums = $wpdb->get_results("SELECT * FROM ".CATEGORY_TABLE." WHERE forum > 0 AND subforum = 0;");
     198                                if ($forums !== false) {
     199                                    foreach ($forums as $forum) {
     200                                        ?>
     201                                        <option value='<?php echo $forum->id; ?>' <?php selected($forum->id, $topic->forum); ?>>
     202                                            <?php echo $forum->name; ?>
     203                                        </option>
     204                                        <?php
     205                                    }
     206                                } else {
     207                                    ?>
     208                                    <div class="wpbb-message-failure">
     209                                        <?php _e('There are no forums', 'wp-bb'); ?>
     210                                    </div>
     211                                    <?php
     212                                    wpbb_exit();
     213                                }
    211214                        // Subforums
    212215                        ?>
     
    258261                </tr>
    259262            <?php
    260         }
     263       
    261264        ?>
    262265        </form>
     
    286289            wpbb_exit();
    287290        }
    288            
    289         if (is_numeric($_POST['wpbbpostauthor'])) {
    290             // Strip all tags from the authors name
    291             $post_author_name = wp_strip_all_tags($_POST['wpbbpostauthor']);
    292             // Retrieve ID back from username
    293             $post_author = wpbb_parse_author_name(NULL, $post_author_name);
    294         } else {
    295             $post_author = absnt($_POST['wpbbpostauthor']);
     291       
     292        $post_author_name = 'Guest';
     293        $post_author = 0;
     294       
     295        if (isset($_POST['wpbbpostauthor'])) {
     296            if (is_numeric($_POST['wpbbpostauthor'])) {
     297                // Strip all tags from the authors name
     298                $post_author_name = wp_strip_all_tags($_POST['wpbbpostauthor']);
     299                // Retrieve ID back from username
     300                $post_author = wpbb_parse_author_name(NULL, $post_author_name);
     301            } else {
     302                $post_author = absnt($_POST['wpbbpostauthor']);
     303            }
    296304        }
    297305           
  • wp-bulletin-board/tags/1.0.3/php/wpbb-functions.php

    r607181 r610404  
    320320function wpbb_get_all_roles($return = 'array') {
    321321    $wp_roles = new WP_Roles();
     322    $options = get_option('wpbb_options');
     323    if ($options['allow_guests'] == 'yes') {
     324        if (!$wp_roles->get_role('guest')) {
     325            $guest_role = $wp_roles->add_role('guest', 'Guest', false);
     326        }
     327    }
    322328    $roles = $wp_roles->get_names();
    323329    $_roles = array();
     
    334340
    335341/**
     342 * Returns only those keys (roles) who match the wp keys (roles)
     343 *
     344 * This function only returns those roles which are available in WP and WPBB (not custom roles that may be used by other plugins but not for the purpose of this plugin)
     345 *
     346 *
     347 * @since 1.0.3
     348 *
     349 * @param    string  $key   The key to check
     350 * @return   bool           True if role matches, false otherwise
     351 *                     
     352 */
     353function wpbb_filter_roles($key) {
     354    $wp_roles = wpbb_get_all_roles();
     355    return (in_array($key, $wp_roles));
     356}
     357
     358function wpbb_user_permission($user_id) {
     359    $user_roles = get_user_meta($user_id, 'wp_capabilities', true);
     360    // Guest
     361    if (empty($user_roles)) {
     362        $options = get_option('wpbb_options');
     363        // Is guest functionality enabled?
     364        if ($options['allow_guests']) {
     365            $user_role_string = 'guest';
     366            return $user_role_string;
     367        }
     368    } else { // Not a guest
     369        $user_role_keys = array_keys($user_roles);
     370        $user_role_keys_filtered = array_filter($user_role_keys, "wpbb_filter_roles"); // < PHP 5.3.0 support
     371        $user_role_string = implode(",", $user_role_keys_filtered);
     372        $user_role_string = strtolower($user_role_string);
     373        return $user_role_string;
     374    }
     375}
     376
     377/**
    336378 * Checks whether the current user ID has permission to do something
    337379 *
     
    355397    $user_roles = get_user_meta($user_id, 'wp_capabilities', true);
    356398   
    357     if (empty($user_roles)) {
    358         wpbb_goback1('forum-index', NULL);
    359         ?>
    360         <div class="wpbb-message-failure">
    361             <?php _e('You do not have the required permissions to access this forum!', 'wp-bb'); ?>
    362         </div>
    363         <?php
    364         wpbb_exit();
    365     }
    366    
    367     $user_role_keys = array_keys($user_roles);
    368 
    369     $user_role_string = implode(",", $user_role_keys);
    370    
    371     $user_role_string = strtolower($user_role_string);
     399    if (!empty($user_roles)) {
     400        $user_role_keys = array_keys($user_roles);
     401   
     402        $user_role_keys_filtered = array_filter($user_role_keys, "wpbb_filter_roles"); // < PHP 5.3.0 support
     403
     404        $user_role_string = implode(",", $user_role_keys_filtered);
     405   
     406        $user_role_string = strtolower($user_role_string);
     407       
     408    } else { // User is considered a guest
     409   
     410        $options = get_option('wpbb_options');
     411        // Is guest functionality enabled?
     412        if ($options['allow_guests']) {
     413           
     414            $user_role_string = 'guest';
     415           
     416        } else { // Show them the door...
     417       
     418            wpbb_goback1();
     419            ?>
     420            <div class="wpbb-centered-bold">
     421                <?php printf(__('You must <a href="%s">Login</a> or <a href="%s">Register</a> to be able to view the forum!'), wp_login_url(), site_url('wp-login.php?action=register')); ?>
     422            </div>
     423            <?php
     424            wpbb_exit();
     425        }
     426    }
    372427   
    373428    $forum_permissions = $wpdb->get_results("SELECT `view`, `read`, `post`, `reply`, `edit`, `lock`, `delete`, `sticky` FROM ".CATEGORIES_TABLE." WHERE id = $forum_id;");
     
    750805
    751806/**
    752  * Updates a users last post date
     807 * Updates a users (including guests) last post date
    753808 *
    754809 * When a user creates a topic or posts a reply / quick reply, this function updates their wpbb_lastpost meta key value
    755  *
    756  * @since 1.0.0
     810 * As of 1.0.3, updates a guests last post as well
     811 *
     812 * @since 1.0.3
    757813 *
    758814 * @param    int    $user_id    The user ID
     
    761817function wpbb_update_user_lastpost($user_id) {
    762818    $date = date("Y-m-d H:i:s");
    763     $update_user_lastpost = update_user_meta($user_id, 'wpbb_lastpost', $date);
     819    if ($user_id == 0) {
     820        update_option('wpbb_guest_options', array('guest_last_post' => $date));
     821    } else {
     822        $update_user_lastpost = update_user_meta($user_id, 'wpbb_lastpost', $date);
     823    }
    764824}
    765825
     
    890950}
    891951
     952function wpbb_moderate_links($where = 'forum', $which = 'topic', $user_id, $forum, $subforum, $topic, $post, $created) {
     953    if ($which == 'topic') {
     954        $edit_permissions = wpbb_user_has_permission($user_id, $forum, 'edit');
     955        $lock_permissions = wpbb_user_has_permission($user_id, $forum, 'lock');
     956        $sticky_permissions = wpbb_user_has_permission($user_id, $forum, 'sticky');
     957        $delete_permissions = wpbb_user_has_permission($user_id, $forum, 'delete');
     958        $edit_topic_link = $lock_topic_link = $sticky_topic_link = $delete_topic_link = NULL;
     959        if ($where == 'forum') {
     960            if ($edit_permissions) {
     961                $edit_topic_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic, 'action' => 'edit'), wpbb_permalink()));
     962            }
     963            if ($lock_permissions) {
     964                $lock_topic_link = sprintf(__('<a href="%s">Lock</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic, 'action' => 'lock'), wpbb_permalink()));
     965            }
     966            if ($sticky_permissions) {
     967                $sticky_topic_link = sprintf(__('<a href="%s">Sticky</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic, 'action' => 'sticky'), wpbb_permalink()));
     968            }
     969            if ($delete_permissions) {
     970                $delete_topic_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic, 'action' => 'delete'), wpbb_permalink()));
     971            }
     972        } elseif ($where == 'subforum') {
     973            if ($edit_permissions) {
     974                $edit_topic_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic, 'action' => 'edit'), wpbb_permalink()));
     975            }
     976            if ($lock_permissions) {   
     977                $lock_topic_link = sprintf(__('<a href="%s">Lock</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic, 'action' => 'lock'), wpbb_permalink()));
     978            }   
     979            if ($sticky_permissions) { 
     980                $sticky_topic_link = sprintf(__('<a href="%s">Sticky</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic, 'action' => 'sticky'), wpbb_permalink()));
     981            }   
     982            if ($delete_permissions) { 
     983                $delete_topic_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic, 'action' => 'delete'), wpbb_permalink()));
     984            }
     985        }
     986        echo $edit_topic_link . " " . $lock_topic_link . " " . $sticky_topic_link . " " . $delete_topic_link . " " . $created;
     987    } elseif ($which == 'post') {
     988        $edit_permissions = wpbb_user_has_permission($user_id, $forum, 'edit');
     989        $delete_permissions = wpbb_user_has_permission($user_id, $forum, 'delete');
     990        $edit_post_link = $delete_post_link = NULL;
     991        if ($where == 'forum') {
     992            if ($edit_permissions) {
     993                $edit_post_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic, 'post' => $post, 'action' => 'edit'), wpbb_permalink()));
     994            }
     995            if ($delete_permissions) {
     996                $delete_post_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic, 'post' => $post, 'action' => 'delete'), wpbb_permalink()));
     997            }
     998        }
     999        elseif ($where == 'subforum') {
     1000            if ($edit_permissions) {
     1001                $edit_post_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic, 'post' => $post, 'action' => 'edit'), wpbb_permalink()));
     1002            }
     1003            if ($delete_permissions) {
     1004                $delete_post_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic, 'post' => $post, 'action' => 'delete'), wpbb_permalink()));
     1005            }
     1006        }
     1007        echo $edit_post_link . " " . $delete_post_link . " " . $created;
     1008    }
     1009}
     1010
    8921011?>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-reply-topic.php

    r607181 r610404  
    77$subforum_id = NULL;
    88
    9 wpbb_goback1('reply-topic', NULL);
    10 
     9wpbb_goback1();
    1110
    1211?> <h2 class="wpbb-centered-bold"> <?php _e('Post Reply', 'wp-bb'); ?> </h2> <?php
     
    2524
    2625$topic_id = absint($_GET['topic']);
    27    
    28 
    29    
     26
    3027// Check forum permissions
    3128$view_permissions = wpbb_user_has_permission($user_id, $forum_id);
    3229if ($view_permissions === false) {
    33     wpbb_goback1('reply-topic-denied', NULL);
    3430    ?>
    3531    <div class="wpbb-message-failure">
     
    4238        $view_permissions = wpbb_user_has_permission($user_id, $subforum_id);
    4339        if ($view_permissions === false) {
    44             wpbb_goback1('reply-topic-denied', NULL);
    4540            ?>
    4641            <div class="wpbb-message-failure">
     
    5348        $reply_permissions = wpbb_user_has_permission($user_id, $forum_id, 'reply');
    5449        if ($reply_permissions === false) {
    55             wpbb_goback1('reply-topic-denied', NULL);
    5650            ?>
    5751            <div class="wpbb-message-failure">
     
    6256        }
    6357    }
     58    // Is topic locked? If so deny access to all except admins and users with lock permissions
     59    $topic_status = wpbb_get_topic_status($topic_id);
     60    if (strpos($topic_status, 'locked') !== false) {
     61        $lock_permissions = wpbb_user_has_permission($user_id, $forum_id, 'lock');
     62        if (!current_user_can('manage_options')) {
     63            // Not an admin, but has lock permissions?
     64            if ($lock_permissions == false) {
     65                wpbb_goback1();
     66                ?>
     67                <div class="wpbb-message-failure">
     68                    <?php _e('You do not have the required permissions to reply to lock topics!', 'wp-bb'); ?>
     69                </div>
     70                <?php
     71                wpbb_exit();
     72            }
     73        }
     74    }
    6475}
    6576
     
    6879if (isset($_POST['wpbb-reply-submit'])) {
    6980
    70     $user_id = get_current_user_id();
     81    $user_roles = wpbb_user_permission($user_id);
     82       
     83    $wpbb_options = get_option('wpbb_options');
     84           
     85    // Retrieve the delay between posts
     86    $post_cutoff = $wpbb_options['post_cutoff'];
     87   
     88    if ($user_roles == 'guest') {
     89        $user_id = 0;
     90        $guest_options = get_option('wpbb_guest_options');
     91        $user_last_post = $guest_options['guest_last_post'];
     92    } else {
     93        $user_id = get_current_user_id();
     94        // Get the users last post
     95        $user_last_post = get_user_meta($user_id, 'wpbb_lastpost', true);
     96    }
     97    // Get the current date as a formatted date string
     98    $current_date = date('Y-m-d H:i:s');
     99           
     100    // Convert post cutoff to seconds
     101    $user_last_post_secs = strtotime($user_last_post);
     102           
     103    // Topic cutoff delay in seconds multiplied by the user last post in seconds will be the number of seconds
     104    // in the future when that delay has passed
     105    $delay_passed_secs = $user_last_post_secs + $post_cutoff;
     106           
     107    // We then convert those seconds to a formatted date string using our seconds as the timestamp
     108    $delay_passed_date = date('Y-m-d H:i:s', $delay_passed_secs);
     109       
     110    $forum_id = absint($_GET['forum']);
     111       
     112    // If the current date is less than the delay_passed_date then we should not be allowed to create another topic
     113    // untill that time has passed.
     114    if ($current_date < $delay_passed_date) {
     115        wpbb_goback1();
     116        ?>
     117        <div class="wpbb-message-failure">
     118            <?php printf(__('You must wait %s seconds since your last post before creating another.'), $post_cutoff); ?>
     119        </div>
     120        <?php
     121        wpbb_exit();
     122    }
    71123   
    72124    $topic_id = absint($_GET['topic']);
    73125   
    74126    $content = wpbb_strip_tags($_POST['wpbb-reply-content']);
     127   
     128    $topic_status = (isset($_POST['wpbb-topic-status'])) ? implode(",", (array) $_POST['wpbb-topic-status']) : "";
    75129
    76130    $create_post = $wpdb->insert(POST_TABLE, array('author' => $user_id, 'topic' => $topic_id, 'text' => $content));
     
    78132    $date = date("Y-m-d H:i:s");
    79133   
    80     $update_topic_last_reply = $wpdb->update(TOPIC_TABLE, array('last_reply' => $date), array('id' => $topic_id));
     134    // Update topics last reply and status
     135    $update_topic_last_reply = $wpdb->update(TOPIC_TABLE, array('last_reply' => $date, 'status' => $topic_status), array('id' => $topic_id));
    81136   
    82137    if ($update_topic_last_reply === false) {
    83         wpbb_goback1('reply-topic-error', NULL);
    84         _e('Error: Failed to update the topics last reply. It is likely the topic doesn\'t exist or was deleted', 'wp-bb');
     138        $update_topic_last_reply_err = __('Error: Failed to update the topics last reply. It is likely the topic doesn\'t exist or was deleted', 'wp-bb');
     139        error_log($update_topic_last_reply_err);
    85140    }
    86141   
    87142    if ($create_post === false) {
    88         wpbb_goback1('reply-topic-error', NULL);
    89143        ?>
    90144        <div class="wpbb-message-error">
     
    93147        <?php
    94148    } else {
    95         wpbb_goback1('reply-topic-success', NULL);
    96149        ?>
    97150        <div class="wpbb-message-success">
     
    99152        </div>
    100153        <?php
    101         wpbb_update_user_meta($user_id, 'increase');
     154        if ($user_roles != 'guest') {
     155            wpbb_update_user_meta($user_id, 'increase');
     156        }
    102157        wpbb_update_user_lastpost($user_id);
    103158    }   
     
    114169            </td>
    115170        </tr>
     171        <?php
     172        $lock_permissions = wpbb_user_has_permission($user_id, $forum_id, 'lock');
     173        $sticky_permissions = wpbb_user_has_permission($user_id, $forum_id, 'sticky');
     174        if ($lock_permissions || $sticky_permissions || current_user_can('manage_options')) {
     175            ?>
     176            <tr>
     177                <th><?php _e('Status', 'wp-bb'); ?></th>
     178                <td>
     179                <?php
     180                if ($lock_permissions || current_user_can('manage_options')) {
     181                    $locked = (strpos($topic_status, 'locked') !== false) ? true : false;
     182                    ?>
     183                    <input type="checkbox" name="wpbb-topic-status[]" value="locked" <?php echo checked($locked, true, false); ?>/> <?php _e('Locked', 'wp-bb');
     184                }
     185                if ($sticky_permissions || current_user_can('manage_options')) {
     186                    $sticky = (strpos($topic_status, 'sticky') !== false) ? true : false;
     187                    ?>
     188                    <input type="checkbox" name="wpbb-topic-status[]" value="sticky" <?php echo checked($sticky, true, false); ?>/> <?php _e('Sticky', 'wp-bb');
     189                }
     190                ?>
     191                </td>
     192            </tr>
     193            <?php
     194        }
     195        ?>
    116196        <tr>
    117197            <th></th>
     
    120200    </form>
    121201</table>
    122 
    123202<?php
    124 
    125 
    126203?>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-unanswered-topics.php

    r607181 r610404  
    9898                        <td><?php echo $topic_link; ?></td>
    9999                        <td>
    100                             <a href='<?php echo add_query_arg(array('profile' => $topic->author), wpbb_permalink()); ?>'><?php echo $topic_author_name; ?></a>
     100                            <?php if ($topic_author_name !=  "") {
     101                                ?>
     102                                <a href='<?php echo add_query_arg(array('profile' => $topic->author), wpbb_permalink()); ?>'><?php echo $topic_author_name; ?></a>
     103                                <?php
     104                            } else {
     105                                _e('Guest', 'wp-bb');
     106                            }
     107                            ?>
    101108                        </td>
    102109                        <td><?php echo $topic_last_post; ?></td>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-view-forum-topic.php

    r607181 r610404  
    2525            ?>
    2626            <div class="wpbb-message-failure">
    27                 <?php _e('You do not have the required permissions to read this topics in this forum!', 'wp-bb'); ?>
    28             </div>
    29             <?php
    30             wpbb_exit();
    31         }
    32     }
    33 
    34    
    35    
     27                <?php _e('You do not have the required permissions to read topics in this forum!', 'wp-bb'); ?>
     28            </div>
     29            <?php
     30            wpbb_exit();
     31        }
     32    }
    3633    $topic_status = wpbb_get_topic_status($topic_id);
    37    
    3834    if (strpos($topic_status, 'locked') !== false) {
    3935        $locked_permissions = wpbb_user_has_permission($user_id, $forum, 'lock');
    4036        // If user does not have lock permissions or is not an admin they cannot view a locked topic!
    4137        if ($locked_permissions === false && !current_user_can('manage_options')) {
    42             wpbb_goback1('forum_topic_denied', NULL);
     38            wpbb_goback1();
    4339            ?>
    4440            <div class="wpbb-message-failure">
     
    5248   
    5349    if (isset($_POST['wpbb-quick-reply-submit'])) {
    54    
    55         // Check user has permissions to reply to the topic
    56        
    57         $user_id = get_current_user_id(); // Third parameter is 'view' by default
    58    
    59         $forum_id = absint($_GET['forum']);
    60        
    61         /*
    62             Check the post cutoff delay has passed
    63         */
    64    
    65         // Get the options
     50       
     51        $user_roles = wpbb_user_permission($user_id);
     52       
    6653        $wpbb_options = get_option('wpbb_options');
    67    
     54           
    6855        // Retrieve the delay between posts
    6956        $post_cutoff = $wpbb_options['post_cutoff'];
    7057   
    71         // Get the users last post
    72         $user_last_post = get_user_meta($user_id, 'wpbb_lastpost', true);
    73    
     58        if ($user_roles == 'guest') {
     59            $user_id = 0;
     60            $guest_options = get_option('wpbb_guest_options');
     61            $user_last_post = $guest_options['guest_last_post'];
     62        } else {
     63            $user_id = get_current_user_id();
     64            // Get the users last post
     65            $user_last_post = get_user_meta($user_id, 'wpbb_lastpost', true);
     66        }
     67       
    7468        // Get the current date as a formatted date string
    7569        $current_date = date('Y-m-d H:i:s');
    76    
     70           
    7771        // Convert post cutoff to seconds
    7872        $user_last_post_secs = strtotime($user_last_post);
    79    
     73           
    8074        // Topic cutoff delay in seconds multiplied by the user last post in seconds will be the number of seconds
    8175        // in the future when that delay has passed
    8276        $delay_passed_secs = $user_last_post_secs + $post_cutoff;
    83    
     77           
    8478        // We then convert those seconds to a formatted date string using our seconds as the timestamp
    8579        $delay_passed_date = date('Y-m-d H:i:s', $delay_passed_secs);
    86    
     80       
     81        $forum_id = absint($_GET['forum']);
     82       
    8783        // If the current date is less than the delay_passed_date then we should not be allowed to create another topic
    8884        // untill that time has passed.
    8985        if ($current_date < $delay_passed_date) {
    90             wpbb_goback1('forum_topic_delay', NULL);
     86            wpbb_goback1();
    9187            ?>
    9288            <div class="wpbb-message-failure">
     
    119115            }
    120116        }
    121         $author = get_current_user_id();
    122         $topic = $topic_id;
    123117        $content = wpbb_strip_tags($_POST['wpbb-quick-reply-content']);
    124         $perms = 'subscriber,contributor,author,editor,administrator';
    125         $create_post = $wpdb->insert(POST_TABLE, array('author' => $author, 'topic' => $topic, 'text' => $content));
     118        $create_post = $wpdb->insert(POST_TABLE, array('author' => $user_id, 'topic' => $topic_id, 'text' => $content));
    126119        $date = date("Y-m-d H:i:s");
    127120        $update_topic_last_reply = $wpdb->update(TOPIC_TABLE, array('last_reply' => $date), array('id' => $topic_id));
    128         //$update_topic_last_reply = $wpdb->query("UPDATE $wpdb->posts SET last_reply = $date WHERE id = $topic;");
    129121        if ($update_topic_last_reply === false) {
    130122            _e('Error: Failed to update the topics last reply. It is likely the topic doesn\'t exist or was deleted', 'wp-bb');
     
    144136            </div>
    145137            <?php
    146             wpbb_update_user_meta($user_id, 'increase');
     138            if ($user_roles != 'guest') {
     139                wpbb_update_user_meta($user_id, 'increase');
     140            }
    147141            wpbb_update_user_lastpost($user_id);
    148142        }
     
    157151    if ($topics) {
    158152        foreach ($topics as $topic) {
    159             $edit_topic_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'edit'), get_permalink()));
    160             $lock_topic_link = sprintf(__('<a href="%s">Lock</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'lock'), get_permalink()));
    161             $sticky_topic_link = sprintf(__('<a href="%s">Sticky</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'sticky'), get_permalink()));
    162             $delete_topic_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'delete'), get_permalink()));
    163153            $options = get_option('wpbb_options');
    164154            $posts_per_page = $options['posts_per_page'];
     
    206196                            ?>
    207197                            <td class="wpbb-topic-profile">
    208                                 <?php _e('Deleted', 'wp-bb'); ?>
     198                                <?php _e('Guest', 'wp-bb'); ?>
    209199                                <br />
    210                                 <?php get_avatar(0, 96, '', false); ?>
     200                                <?php echo get_avatar(0); ?>
    211201                            </td>
    212202                            <?php
     
    227217                        <td>
    228218                            <p class="wpbb-topic-and-post-date">
    229                                 <?php echo $edit_topic_link." ".$lock_topic_link." ".$sticky_topic_link." ".$delete_topic_link." ".$topic->created; ?>
     219                                <?php wpbb_moderate_links('forum', 'topic', $user_id, $forum, NULL, $topic->id, NULL, $topic->created); ?>
    230220                            </p>
    231221                            <p class="wpbb-topic-and-post-content">
     
    243233                if ($posts) {
    244234                    foreach ($posts as $post) {
    245                    
    246                     $current_page_arg = remove_query_arg('current_page');
    247                    
    248                     $edit_post_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'post' => $post->id, 'action' => 'edit'), $current_page_arg));
    249                    
    250                     $delete_post_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'post' => $post->id, 'action' => 'delete'), $current_page_arg));
    251                    
    252                    
    253235                    $user_posts = get_user_meta($post->author, 'wpbb_posts', true);
    254                    
    255236                    $signature = get_user_meta($post->author, 'wpbb_signature', true);
    256                    
    257237                    $author = get_userdata($post->author);
    258                    
    259                     if (!$author) {
    260                         $author->display_name = 'Deleted';
    261                     }
    262238                    ?>
    263239                    <tr>
    264240                        <td class="wpbb-topic-profile">
    265                             <a href='<?php echo add_query_arg(array('profile' => $post->author), wpbb_permalink()); ?>'><?php echo $author->display_name; ?></a>
    266                             <br /><?php echo get_avatar($post->author); ?>
    267                             <br /><?php printf(__('Posts: %s'), $user_posts); ?>
     241                            <?php
     242                            if (!$author) {
     243                                _e('Guest', 'wpbb');
     244                                ?>
     245                                <br />
     246                                <?php
     247                                echo get_avatar(0);
     248                            } else {   
     249                                ?>
     250                                <a href='<?php echo add_query_arg(array('profile' => $post->author), wpbb_permalink()); ?>'><?php echo $author->display_name; ?></a>
     251                                <br /><?php echo get_avatar($post->author); ?>
     252                                <br /><?php printf(__('Posts: %s'), $user_posts);
     253                            }
     254                            ?>
    268255                        </td>
    269256                        <td>
    270257                            <p class="wpbb-topic-and-post-date">
    271                                 <?php echo $edit_post_link." ".$delete_post_link." ".$post->created; ?>
     258                                <?php wpbb_moderate_links('forum', 'post', $user_id, $forum, NULL, $topic->id, $post->id, $post->created); ?>
    272259                            </p>
    273260                            <p class="wpbb-topic-and-post-content">
  • wp-bulletin-board/tags/1.0.3/php/wpbb-view-forum.php

    r607181 r610404  
    132132                        ?>
    133133                        <td>
    134                             <?php _e('Deleted', 'wp-bb'); ?>
     134                            <?php _e('Guest', 'wp-bb'); ?>
    135135                        </td>
    136136                        <?php
     
    148148                    <td><?php echo $topic_last_post; ?></td>
    149149                    <td>
    150                         <a href='<?php echo add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'edit'), get_permalink()); ?>'>
    151                             <?php _e('Edit', 'wp-bb'); ?>
    152                         </a>
    153                         <a href='<?php echo add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'lock'), get_permalink()); ?>'>
    154                             <?php _e('Lock', 'wp-bb'); ?>
    155                         </a>
    156                         <a href='<?php echo add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'sticky'), get_permalink()); ?>'>
    157                             <?php _e('Sticky', 'wp-bb'); ?>
    158                         </a>
    159                         <a href='<?php echo add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'action' => 'delete'), get_permalink()); ?>'>
    160                             <?php _e('Delete', 'wp-bb'); ?>
    161                         </a>
     150                        <?php wpbb_moderate_links('forum', 'topic', $user_id, $forum, NULL, $topic->id, NULL, NULL); ?>
    162151                    </td>
    163152                </tr>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-view-profile.php

    r607181 r610404  
    99*/
    1010   
    11     $profile_id = absint($_GET['profile']);
     11$profile_id = absint($_GET['profile']);
     12
     13$user = get_user_by('id', $profile_id);
    1214   
    13     $user = get_user_by('id', $profile_id);
    14    
    15     // Guest
    16     if ($user === false) {
    17         ?>
    18         <div class="wpbb-centered-bold">
    19             <?php printf(__('You must <a href="%s">Login</a> or <a href="%s">Register</a> to be able to view the forum!'), wp_login_url(), site_url('wp-login.php?action=register')); ?>
    20         </div>
    21         <?php
    22         wpbb_exit();
    23     }
    24    
    25     wpbb_goback1();
     15
     16
     17
     18wpbb_goback1();
    2619   
    2720   
    28     if ($profile_id == $user_id) {
    29         ?>
    30         <h1 id="wpbb-h-1" class="wpbb-centered-bold">
    31             <?php _e('My Profile', 'wp-bb'); ?>
    32         </h1>
    33         <?php
    34     } else {
    35         ?>
    36         <h1 id="wpbb-h-1" class="wpbb-centered-bold">
    37             <?php printf(__('Viewing %s\'s Profile'), $user->display_name); ?>
    38         </h1>
    39         <?php
     21if ($profile_id == $user_id) {
     22    ?>
     23    <h1 id="wpbb-h-1" class="wpbb-centered-bold">
     24        <?php _e('My Profile', 'wp-bb'); ?>
     25    </h1>
     26    <?php
     27} else {
     28    ?>
     29    <h1 id="wpbb-h-1" class="wpbb-centered-bold">
     30        <?php printf(__('Viewing %s\'s Profile'), $user->display_name); ?>
     31    </h1>
     32    <?php
     33}
     34
     35$roles = implode(",", $user->roles);
     36   
     37$posts = get_user_meta($profile_id, 'wpbb_posts', true);
     38   
     39$signature = get_user_meta($profile_id, 'wpbb_signature', true);
     40   
     41if ($user) {
     42    if (isset($_POST['wpbb-signature-submit'])) {   
     43        $signature = wpbb_strip_tags($_POST['wpbb-signature']);
     44        $add_user_meta = update_user_meta($profile_id, 'wpbb_signature', $signature);
     45        if ($add_user_meta === false) {
     46            ?>
     47            <div class="wpbb-message-failure">
     48                <?php _e('There was an error saving your signature, please try again', 'wp-bb'); ?>
     49            </div>
     50            <?php
     51        }
    4052    }
     53}
     54?>
    4155
    42    
    43     $roles = implode(",", $user->roles);
    44    
    45    
    46     $posts = get_user_meta($profile_id, 'wpbb_posts', true);
    47    
    48     $signature = get_user_meta($profile_id, 'wpbb_signature', true);
    49    
    50     if ($user) {
    51    
    52         if (isset($_POST['wpbb-signature-submit'])) {
    53            
    54             $signature = wpbb_strip_tags($_POST['wpbb-signature']);
    55            
    56             $add_user_meta = update_user_meta($profile_id, 'wpbb_signature', $signature);
    57            
    58             if ($add_user_meta === false) {
    59                
    60                 ?>
    61                 <div class="wpbb-message-failure">
    62                     <?php _e('There was an error saving your signature, please try again', 'wp-bb'); ?>
    63                 </div>
    64                 <?php
    65             }
    66         }
    67         ?>
    68        
    69        
    70     <div>
    71         <table id="wpbb-profile-table">
    72             <tr valign=top>
    73                 <td id="wpbb-profile-table-name-avatar">
    74                     <?php echo $user->display_name; ?>
    75                     <br />
    76                     <?php echo get_avatar($profile_id); ?>
    77                     <br />
    78                     <a href="<?php echo add_query_arg(array('message' => $profile_id), wpbb_permalink()); ?>">Message</a>
    79                 </td>
    80                 <td>
     56<div>
     57    <table id="wpbb-profile-table">
     58        <tr valign=top>
     59            <td id="wpbb-profile-table-name-avatar">
     60                <?php echo $user->display_name; ?>
     61                <br />
     62                <?php echo get_avatar($profile_id); ?>
     63                <br />
     64                <a href="<?php echo add_query_arg(array('message' => $profile_id), wpbb_permalink()); ?>">Message</a>
     65            </td>
     66            <td>
    8167                <table id="wpbb-profile-table-stats">
    8268                    <tr>
     
    123109                    </tr>
    124110                </table>
    125             </tr>
    126         </table>
     111            </td>
     112        </tr>
     113    </table>
     114</div>
     115           
     116<div class="clear"></div>
     117<div class="clear"></div>
     118
     119<?php
     120if ($profile_id == $user_id) {
     121    ?>
     122    <div id="wpbb-profile-signature">
     123        <form method="POST" action="#">
     124            <div>
     125                <h2><?php _e('Signature', 'wp-bb'); ?></h2>
     126            </div>
     127            <div>
     128                <textarea name="wpbb-signature"><?php echo $signature; ?></textarea>
     129            </div>
     130            <div>
     131                <input type="submit" name="wpbb-signature-submit" value="<?php _e('Save Signature', 'wp-bb'); ?>" />
     132            </div>
     133        </form>
    127134    </div>
    128            
    129         <div class="clear"></div>
    130        
    131        
    132         <div class="clear"></div>
    133         <div id="wpbb-profile-signature">
    134             <form method="POST" action="#">
    135                 <div>
    136                     <h2><?php _e('Signature', 'wp-bb'); ?></h2>
    137                 </div>
    138                 <div>
    139                     <textarea name="wpbb-signature"><?php echo $signature; ?></textarea>
    140                 </div>
    141                 <div>
    142                     <input type="submit" name="wpbb-signature-submit" value="<?php _e('Save Signature', 'wp-bb'); ?>" />
    143                 </div>
    144             </form>
    145         </div>
    146         <?php
    147     }
     135    <?php
     136}
     137
    148138?>
  • wp-bulletin-board/tags/1.0.3/php/wpbb-view-subforum-topic.php

    r607181 r610404  
    4747        }
    4848    }
     49    // Is topic locked? If so deny access to all except admins and users with lock permissions
     50    $topic_status = wpbb_get_topic_status($topic_id);
     51    if (strpos($topic_status, 'locked') !== false) {
     52        $lock_permissions = wpbb_user_has_permission($user_id, $forum, 'lock');
     53        if (!current_user_can('manage_options')) {
     54            // Not an admin, but has lock permissions?
     55            if ($lock_permissions == false) {
     56                wpbb_goback1();
     57                ?>
     58                <div class="wpbb-message-failure">
     59                    <?php _e('You do not have the required permissions to reply to lock topics!', 'wp-bb'); ?>
     60                </div>
     61                <?php
     62                wpbb_exit();
     63            }
     64        }
     65    }
    4966
    5067    // Quick reply submission
     
    5370        // Check user has permissions to reply to the topic
    5471   
     72        $user_roles = wpbb_user_permission($user_id);
     73       
     74        $wpbb_options = get_option('wpbb_options');
     75           
     76        // Retrieve the delay between posts
     77        $post_cutoff = $wpbb_options['post_cutoff'];
     78   
     79        if ($user_roles == 'guest') {
     80            $user_id = 0;
     81            $guest_options = get_option('wpbb_guest_options');
     82            $user_last_post = $guest_options['guest_last_post'];
     83        } else {
     84            $user_id = get_current_user_id();
     85            // Get the users last post
     86            $user_last_post = get_user_meta($user_id, 'wpbb_lastpost', true);
     87        }
     88       
     89        // Get the current date as a formatted date string
     90        $current_date = date('Y-m-d H:i:s');
     91           
     92        // Convert post cutoff to seconds
     93        $user_last_post_secs = strtotime($user_last_post);
     94           
     95        // Topic cutoff delay in seconds multiplied by the user last post in seconds will be the number of seconds
     96        // in the future when that delay has passed
     97        $delay_passed_secs = $user_last_post_secs + $post_cutoff;
     98           
     99        // We then convert those seconds to a formatted date string using our seconds as the timestamp
     100        $delay_passed_date = date('Y-m-d H:i:s', $delay_passed_secs);
     101       
     102        // If the current date is less than the delay_passed_date then we should not be allowed to create another topic
     103        // untill that time has passed.
     104        if ($current_date < $delay_passed_date) {
     105            wpbb_goback1();
     106            ?>
     107            <div class="wpbb-message-failure">
     108                <?php printf(__('You must wait %s seconds since your last post before creating another.'), $post_cutoff); ?>
     109            </div>
     110            <?php
     111            wpbb_exit();
     112        }
     113       
    55114        $forum_id = absint($_GET['forum']);
    56115        $subforum_id = absint($_GET['subforum']);
     
    90149            }
    91150        }
    92        
    93         $topic = $topic_id;
    94151        $content = wp_strip_all_tags($_POST['wpbb-quick-reply-content']);
    95         $perms = 'subscriber,contributor,author,editor,administrator';
    96         $create_post = $wpdb->insert(POST_TABLE, array('author' => $user_id, 'topic' => $topic, 'text' => $content));
     152        $create_post = $wpdb->insert(POST_TABLE, array('author' => $user_id, 'topic' => $topic_id, 'text' => $content));
    97153        $date = date("Y-m-d H:i:s");
    98154        $update_topic_last_reply = $wpdb->update(TOPIC_TABLE, array('last_reply' => $date), array('id' => $topic_id));
     
    114170            </div>
    115171            <?php
    116             wpbb_update_user_meta($user_id, 'increase');
     172            if ($user_roles != 'guest') {
     173                wpbb_update_user_meta($user_id, 'increase');
     174            }
     175            wpbb_update_user_lastpost($user_id);
    117176        }
    118177    }
     178
    119179
    120180
     
    125185    </h2>
    126186    <?php
     187    wpbb_buttons($forum, $subforum, $topic_id, 'subforum_topic');
     188    ?> <div class="clear"></div><?php
    127189    $topics = $wpdb->get_results("SELECT * FROM ".TOPIC_TABLE." WHERE id = $topic_id;");
    128190    if ($topics) {
     
    134196            <?php
    135197            foreach ($topics as $topic) {
    136                 $edit_topic_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic->id, 'action' => 'edit'), wpbb_permalink()));
    137                 $lock_topic_link = sprintf(__('<a href="%s">Lock</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum,  'topic' => $topic->id, 'action' => 'lock'), wpbb_permalink()));
    138                 $sticky_topic_link = sprintf(__('<a href="%s">Sticky</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum,  'topic' => $topic->id, 'action' => 'sticky'), wpbb_permalink()));
    139                 $delete_topic_link = sprintf(__('<a href="%s">Delete</a>'), add_query_arg(array('forum' => $forum, 'subforum' => $subforum,  'topic' => $topic->id, 'action' => 'delete'), wpbb_permalink()));
    140                
    141                
    142198                $author = get_userdata($topic->author);
    143                 $avatar = get_avatar($topic->author);
    144            
    145199                $signature = get_user_meta($topic->author, 'wpbb_signature', true);
    146            
    147200                // Pagination
    148201                $options = get_option('wpbb_options');
     
    166219                    wpbb_pagination($forum, $current_page, $start, $limit, $total_posts, $posts_per_page, false);
    167220                }
    168                 wpbb_buttons($forum, $subforum, $topic_id, 'subforum_topic');
    169221                if ($current_page == 1) {
    170222                    ?>
    171223                    <tr>
    172224                        <td class="wpbb-topic-profile">
    173                             <a href='<?php echo add_query_arg(array('profile' => $topic->author), wpbb_permalink()); ?>'>
    174                                 <?php echo $author->display_name; ?>
    175                             </a>
    176                             <br /><?php echo $avatar; ?>
     225                            <?php if ($author) {
     226                                ?>
     227                                <a href='<?php echo add_query_arg(array('profile' => $topic->author), wpbb_permalink()); ?>'>
     228                                    <?php
     229                                    echo $author->display_name;
     230                                    $id = $topic->author;
     231                                    ?>
     232                                </a>
     233                                <?php
     234                            } else {
     235                                _e('Guest', 'wp-bb');
     236                                $id = 0;
     237                            }
     238                            ?>
     239                            <br /><?php echo get_avatar($id); ?>
    177240                        </td>
    178241                        <td>
    179                             <p class="wpbb-topic-and-post-date">
    180                                 <?php echo $edit_topic_link." ".$lock_topic_link." ".$sticky_topic_link." ".$delete_topic_link." ".$topic->created; ?>
     242                            <p class="wpbb-topic-and-post-date"> 
     243                                <?php wpbb_moderate_links('subforum', 'topic', $user_id, $forum, $subforum, $topic->id, NULL, $topic->created); ?>
    181244                            </p>
    182245                            <p class="wpbb-topic-and-post-content">
     
    195258                if ($posts) {
    196259                    foreach ($posts as $post) {
    197                         $edit_post_link = sprintf(__('<a href="%s">Edit</a>'), add_query_arg(array('forum' => $forum, 'topic' => $topic->id, 'post' => $post->id, 'action' => 'edit'), wpbb_permalink()));
    198260                        $author = get_userdata($post->author);
    199                         $avatar = get_avatar($post->author);
    200261                        $signature = get_user_meta($post->author, 'wpbb_signature', true);
    201262                        ?>
    202263                        <tr>
    203264                            <td class="wpbb-topic-profile">
    204                                 <a href='<?php echo add_query_arg(array('profile' => $post->author), wpbb_permalink()); ?>'>
    205                                     <?php echo $author->display_name; ?>
    206                                 </a>
     265                                <?php
     266                                if ($author) {
     267                                    ?>
     268                                    <a href='<?php echo add_query_arg(array('profile' => $post->author), wpbb_permalink()); ?>'>
     269                                        <?php
     270                                            echo $author->display_name;
     271                                            $id = $post->author;
     272                                        ?>
     273                                    </a>
     274                                    <?php
     275                                } else {
     276                                    _e('Guest', 'wpbb');
     277                                    $id = 0;
     278                                }
     279                                ?>
    207280                                <br />
    208                                 <?php echo $avatar; ?>
     281                                <?php echo get_avatar($id); ?>
    209282                            </td>
    210283                            <td>
    211284                                <p class="wpbb-topic-and-post-date">
    212                                     <?php echo $edit_post_link." ".$post->created; ?>
     285                                    <?php wpbb_moderate_links('subforum', 'post', $user_id, $forum, $subforum, $topic->id, $post->id, $post->created);; ?>
    213286                                </p>
    214287                                <p class="wpbb-topic-and-post-content">
  • wp-bulletin-board/tags/1.0.3/php/wpbb-view-subforum.php

    r607181 r610404  
    100100                </td>
    101101                <td class="wpbb-centered">
    102                     <a href='<?php echo add_query_arg(array('profile' => $topic->author), wpbb_permalink()); ?>'><?php echo $author->display_name; ?></a>
     102                    <?php if ($author) {
     103                        ?>
     104                        <a href='<?php echo add_query_arg(array('profile' => $topic->author), wpbb_permalink()); ?>'><?php echo $author->display_name; ?></a>
     105                        <?php
     106                    } else {
     107                        _e('Guest', 'wp-bb');
     108                    }
     109                    ?>
    103110                </td>
    104111                <td>
     
    109116                </td>
    110117                <td>
    111                     <a href='<?php echo add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic->id, 'action' => 'edit'), get_permalink()); ?>'>
    112                         <?php _e('Edit', 'wp-bb'); ?>
    113                     </a>
    114                     <a href='<?php echo add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic->id, 'action' => 'lock'), get_permalink()); ?>'>
    115                         <?php _e('Lock', 'wp-bb'); ?>
    116                     </a>
    117                     <a href='<?php echo add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic->id, 'action' => 'sticky'), get_permalink()); ?>'>
    118                         <?php _e('Sticky', 'wp-bb'); ?>
    119                     </a>
    120                     <a href='<?php echo add_query_arg(array('forum' => $forum, 'subforum' => $subforum, 'topic' => $topic->id, 'action' => 'delete'), get_permalink()); ?>'>
    121                         <?php _e('Delete', 'wp-bb'); ?>
    122                     </a>
     118                    <?php wpbb_moderate_links('subforum', 'topic', $user_id, $forum, $subforum, $topic->id, NULL, NULL); ?>
    123119                </td>
    124120            </tr>
Note: See TracChangeset for help on using the changeset viewer.