Changeset 139
- Timestamp:
- 06/11/2005 09:50:08 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
-
bb-admin/upgrade-schema.php (modified) (1 diff)
-
bb-admin/upgrade.php (modified) (2 diffs)
-
bb-includes/functions.php (modified) (5 diffs)
-
bb-includes/template-functions.php (modified) (3 diffs)
-
bb-post.php (modified) (2 diffs)
-
bb-templates/post-form.php (modified) (1 diff)
-
bb-templates/topic.php (modified) (1 diff)
-
tag-add.php (modified) (1 diff)
-
tag-remove.php (modified) (1 diff)
-
topic-resolve.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-admin/upgrade-schema.php
r121 r139 37 37 forum_id int(10) NOT NULL default '1', 38 38 topic_status tinyint(1) NOT NULL default '0', 39 topic_resolved varchar(15) NOT NULL default 'no', 39 40 topic_open tinyint(1) NOT NULL default '1', 40 41 topic_last_post_id bigint(20) NOT NULL default '1', -
trunk/bb-admin/upgrade.php
r121 r139 4 4 set_time_limit(600); 5 5 // Uncomment to use. Best to run one at a time 6 7 /* Add _topics.topic_resolved column 8 $bbdb->query("ALTER TABLE $bbdb->topics ADD topic_resolved VARCHAR(15) DEFAULT 'no' NOT NULL AFTER topic_status"); 9 echo "Done with adding topic_resolved column\n"; 10 flush(); 11 */ 6 12 7 13 /* Populate _topics.topic_start_time: June 3rd, 2005 … … 17 23 unset($topics); 18 24 echo "Done with adding topic_start_time...\n"; 25 flush(); 26 */ 27 28 /* Add _topics.topic_start_time column 29 $bbdb->query("ALTER TABLE $bbdb->topics ADD topic_start_time DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER topic_last_poster_name"); 30 echo "Done with adding topic_start_time column\n"; 19 31 flush(); 20 32 */ -
trunk/bb-includes/functions.php
r137 r139 344 344 if ( $forum && $title ) { 345 345 $bbdb->query("INSERT INTO $bbdb->topics 346 (topic_title, topic_poster, topic_poster_name, topic_last_poster, topic_last_poster_name, topic_ time, forum_id, topic_start_time)346 (topic_title, topic_poster, topic_poster_name, topic_last_poster, topic_last_poster_name, topic_start_time, topic_time, forum_id) 347 347 VALUES 348 ('$title', $current_user->user_id, '$current_user->username', $current_user->user_id, '$current_user->username', '$now', $forum, '$now')");348 ('$title', $current_user->user_id, '$current_user->username', $current_user->user_id, '$current_user->username', '$now', '$now', $forum)"); 349 349 $topic_id = $bbdb->insert_id; 350 350 if ( !empty( $tags ) ) … … 428 428 } 429 429 430 function bb_resolve_topic ( $topic_id, $resolved = 'yes' ) { 431 global $bbdb; 432 if ( ! in_array($resolved, array('yes', 'no', 'mu')) ) 433 return false; 434 bb_do_action('resolve_topic', $topic_id); 435 return $bbdb->query("UPDATE $bbdb->topics SET topic_resolved = '$resolved' WHERE topic_id = '$topic_id'"); 436 } 437 430 438 function bb_close_topic ( $topic_id ) { 431 439 global $bbdb; … … 545 553 else 546 554 return true; 555 } 556 557 function can_edit_topic( $topic_id, $user_id = 0 ) { 558 global $current_user; 559 if ( empty($current_user) ) 560 return false; 561 if ( ! $user_id ) 562 $user_id = $current_user->user_id; 563 $user = bb_get_user( $user_id ); 564 $topic = get_topic( $topic_id ); 565 $topic_poster = bb_get_user( $topic->topic_poster ); 566 567 if ( $user->user_type > 1) 568 return true; 569 570 if ( $user->user_type > $topic_poster->user_type ) 571 return true; 572 573 if ( $user->user_id != $topic_poster->user_id ) 574 return false; 575 576 if ( ! topic_is_open( $topic_id ) ) 577 return false; 578 579 return true; 547 580 } 548 581 … … 628 661 function add_topic_tag( $topic_id, $tag ) { 629 662 global $bbdb, $current_user; 630 if ( !$tag_id = create_tag( $tag )) 663 if ( !topic_is_open($topic_id) && $current_user->user_type < 1 ) 664 return false; 665 if ( !$tag_id = create_tag( $tag ) ) 631 666 return false; 632 667 $now = bb_current_time('mysql'); … … 696 731 $user = bb_get_user($user_id); 697 732 698 if ( $current_user->user_ id != $user_id && $current_user->user_type < 1)733 if ( $current_user->user_type < 1 && ( !topic_is_open($topic_id) || $current_user->user_id != $user_id ) ) 699 734 return false; 700 735 -
trunk/bb-includes/template-functions.php
r133 r139 288 288 $topic = get_topic( $id ); 289 289 return strtotime( $topic->topic_start_time ); 290 } 291 292 function topic_resolved( $yes = 'resolved', $no = 'not resolved', $mu = 'not a support question', $id = 0 ) { 293 global $current_user, $topic; 294 if ( can_edit_topic( $topic->topic_id ) ) : 295 $resolved_form = '<form id="resolved" method="post" action="' . bb_get_option('uri') . 'topic-resolve.php">' . "\n"; 296 $resolved_form .= '<input type="hidden" name="id" value="' . $topic->topic_id . "\" />\n"; 297 $resolved_form .= '<select name="resolved" tabindex="2">' . "\n"; 298 299 $cases = array( 'yes', 'no', 'mu' ); 300 $resolved = get_topic_resolved( $id ); 301 foreach ( $cases as $case ) { 302 $selected = ( $case == $resolved ) ? ' selected="selected"' : ''; 303 $resolved_form .= "<option value=\"$case\"$selected>${$case}</option>\n"; 304 } 305 306 $resolved_form .= "</select>\n"; 307 $resolved_form .= '<input type="submit" name="submit" value="Change" />' . "\n</form>"; 308 echo $resolved_form; 309 else: 310 switch ( get_topic_resolved( $id ) ) { 311 case 'yes' : echo $yes; break; 312 case 'no' : echo $no; break; 313 case 'mu' : echo $mu; break; 314 } 315 endif; 316 } 317 318 function get_topic_resolved( $id = 0 ) { 319 global $topic; 320 if ( $id ) 321 $topic = get_topic( $id ); 322 return $topic->topic_resolved; 290 323 } 291 324 … … 543 576 544 577 function tag_form() { 545 global $current_user; 546 if ( $current_user ) 578 global $topic, $current_user; 579 if ( !$current_user || $current_user->user_type < 1 && !topic_is_open($topic->topic_id) ) 580 return false; 581 else 547 582 include( BBPATH . '/bb-templates/tag-form.php'); 548 583 } … … 584 619 function tag_remove_link( $tag_id = 0, $user_id = 0, $topic_id = 0 ) { 585 620 global $tag, $current_user; 586 if ( $current_user->user_ id != $tag->user_id && $current_user->user_type < 1)621 if ( $current_user->user_type < 1 && ( !topic_is_open($tag->topic_id) || $current_user->user_id != $tag->user_id ) ) 587 622 return false; 588 623 echo '[<a href="' . bb_get_option('uri') . 'tag-remove.php?tag=' . $tag->tag_id . '&user=' . $tag->user_id . '&topic=' . $tag->topic_id . '" onclick="return confirm(\'Are you sure you want to remove the \\\'' . $tag->raw_tag . '\\\' tag?\')" title="Remove this tag">x</a>]'; -
trunk/bb-post.php
r102 r139 10 10 $topic = trim( $_POST['topic'] ); 11 11 $tags = trim( $_POST['tags'] ); 12 $support = (int) $_POST['support']; 12 13 13 14 if ('' == $topic) … … 15 16 16 17 $topic_id = bb_new_topic( $topic, $forum, $tags ); 18 if ( 1 != $support ) 19 bb_resolve_topic( $topic_id, 'mu' ); 17 20 } elseif ( isset($_POST['topic_id'] ) ) { 18 21 $topic_id = (int) $_POST['topic_id']; -
trunk/bb-templates/post-form.php
r101 r139 7 7 <input name="topic" type="text" id="topic" size="50" maxlength="80" tabindex="1" /> 8 8 </label> 9 <label><input name="support" type="checkbox" id="support" checked="checked" value="1" tabindex="2"/>This is a support question.</label> 9 10 </p> 10 11 <?php endif; ?> 11 12 <p><label>Post:<br /> 12 <textarea name="post_content" cols="50" rows="8" id="post_content" tabindex=" 2"></textarea>13 <textarea name="post_content" cols="50" rows="8" id="post_content" tabindex="3"></textarea> 13 14 </label> 14 15 </p> 15 16 <?php if ( is_forum() || is_tag() ) : ?> 16 17 <p>Enter a few words (called <a href="<?php tag_page_link(); ?>">tags</a>) separated by spaces to help someone find your topic:<br /> 17 <input name="tags" type="text" size="50" maxlength="100" value="<?php tag_name(); ?> " tabindex=" 3" />18 <input name="tags" type="text" size="50" maxlength="100" value="<?php tag_name(); ?> " tabindex="4" /> 18 19 </p> 19 20 <?php endif; ?> -
trunk/bb-templates/topic.php
r138 r139 13 13 <li><?php topic_posts(); ?> posts so far</li> 14 14 <li>Latest reply from <?php topic_last_poster(); ?></li> 15 <li>This topic is <?php topic_resolved(); ?></li> 15 16 </ul> 16 17 <br clear="all" /> -
trunk/tag-add.php
r82 r139 16 16 if ( add_topic_tag( $topic_id, $tag ) ) 17 17 header('Location: ' . get_topic_link( $topic_id ) ); 18 else 19 die('The tag was not added. Either the tag name was invalid or the topic is closed.'); 18 20 ?> -
trunk/tag-remove.php
r120 r139 17 17 header( 'Location: ' . $_SERVER['HTTP_REFERER'] ); 18 18 else 19 die('The tag was not fully removed.');19 die('The tag was not removed. You cannot remove a tag from a closed topic.'); 20 20 exit; 21 21 ?>
Note: See TracChangeset
for help on using the changeset viewer.