Changeset 5484
- Timestamp:
- 12/10/2011 06:19:44 PM (13 years ago)
- Location:
- trunk/bp-activity
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/admin/css/admin.css
r5435 r5484 1 #wp-bp-activities-wrap{padding:5px 0;}#bp-activities{height:120px;}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0;}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center;}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center;}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top;}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px;}#wp-bp-activities-content-wrap{margin-top:20px;}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px;} 1 #wp-bp-activities-wrap{padding:5px 0;}#bp-activities{height:120px;}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0;}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center;}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center;}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top;}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px;}#wp-bp-activities-content-wrap{margin-top:20px;}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px;}#bp_activity_link input{width:99%;}#bp-activities-primaryid{margin-bottom:1em;} -
trunk/bp-activity/admin/css/admin.dev.css
r5435 r5484 40 40 margin-top: -2px; 41 41 } 42 #bp_activity_link input { 43 width: 99%; 44 } 45 #bp-activities-primaryid { 46 margin-bottom: 1em; 47 } -
trunk/bp-activity/bp-activity-admin.php
r5450 r5484 135 135 136 136 /** 137 * Hide the advanced edit meta boxes by default, so we don't clutter the scren. 138 * 139 * @param WP_Screen $screen Screen identifier 140 * @return array Hidden Meta Boxes 141 * @since 1.0 142 */ 143 function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) { 144 if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id ) 145 return $hidden; 146 147 // Hide the primary link meta box by default 148 $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) ); 149 150 return apply_filters( 'bp_hide_meta_boxes', array_unique( $hidden ), $screen ); 151 } 152 add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 ); 153 154 155 /** 137 156 * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page. 138 157 * 158 * @global object $bp BuddyPress global settings 139 159 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table 140 160 * @since 1.6 141 161 */ 142 162 function bp_activity_admin_load() { 143 global $bp _activity_list_table;163 global $bp, $bp_activity_list_table; 144 164 145 165 // Decide whether to load the dev version of the CSS and JavaScript … … 151 171 // Edit screen 152 172 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) { 173 // columns screen option 174 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 175 153 176 get_current_screen()->add_help_tab( array( 154 177 'id' => 'bp-activity-edit-overview', 155 178 'title' => __( 'Overview', 'buddypress' ), 156 179 'content' => 157 '<p>' . __( 'You can edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error.', 'buddypress' ) . '</p>' . 180 '<p>' . __( 'You edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error.', 'buddypress' ) . '</p>' . 181 '<p>' . __( 'The two big editing areas for the activity title and content are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Primary Item/Secondary Item, Link, Type, Author ID) or to choose a 1- or 2-column layout for this screen.', 'buddypress' ) . '</p>' . 158 182 '<p>' . __( 'You can also moderate the activity from this screen using the Status box, where you can also change the timestamp of the activity.', 'buddypress' ) . '</p>' 159 183 ) ); 160 184 185 get_current_screen()->add_help_tab( array( 186 'id' => 'bp-activity-edit-advanced', 187 'title' => __( 'Item, Link, Type', 'buddypress' ), 188 'content' => 189 '<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' . 190 '<p>' . __( '<strong>Link</strong> - Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '</p>' . 191 '<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' . 192 '<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>' 193 ) ); 194 195 // Help panel - sidebar links 196 get_current_screen()->set_help_sidebar( 197 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 198 '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-activity/">Managing Activity</a>', 'buddypress' ) . '</p>' . 199 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 200 ); 201 161 202 // Register metaboxes for the edit screen. 162 add_meta_box( 'submitdiv', _x( 'Status', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_status', 'toplevel_page_bp-activity', 'side', 'core' ); 203 add_meta_box( 'submitdiv', _x( 'Status', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_status', 'toplevel_page_bp-activity', 'side', 'core' ); 204 add_meta_box( 'bp_activity_itemids', _x( 'Primary Item/Secondary Item', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_itemids', 'toplevel_page_bp-activity', 'advanced', 'core' ); 205 add_meta_box( 'bp_activity_link', _x( 'Link', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_link', 'toplevel_page_bp-activity', 'advanced', 'core' ); 206 add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', 'toplevel_page_bp-activity', 'advanced', 'core' ); 207 add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', 'toplevel_page_bp-activity', 'advanced', 'core' ); 163 208 164 209 // Enqueue javascripts … … 168 213 169 214 // Enqueue CSS 170 wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . "bp-activity/admin/css/admin.{$dev}css", array(), '201112 03' );215 wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . "bp-activity/admin/css/admin.{$dev}css", array(), '20111210' ); 171 216 172 217 // Index screen … … 192 237 'title' => __( 'Moderating Activity', 'buddypress' ), 193 238 'content' => 194 '<ul>' . 195 '<li>' . __( 'In the <strong>Activity</strong> column, above each activity it says “Submitted on,” followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress' ) . '</li>' . 196 '<li>' . __( "In the <strong>In Response To</strong> column, if the activity was in reply to another activity, it shows that activity's author's picture and name, and a link to that activity on your live site. If there is a small bubble, the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.", 'buddypress' ) . '</li>' . 197 '</ul>' 239 '<p>' . __( 'In the <strong>Activity</strong> column, above each activity it says “Submitted on,” followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress' ) . '</p>' . 240 '<p>' . __( "In the <strong>In Response To</strong> column, if the activity was in reply to another activity, it shows that activity's author's picture and name, and a link to that activity on your live site. If there is a small bubble, the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.", 'buddypress' ) . '</p>' 198 241 ) ); 242 243 // Help panel - sidebar links 244 get_current_screen()->set_help_sidebar( 245 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 246 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 247 ); 199 248 200 249 // Enqueue CSS and JavaScript … … 202 251 wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . "bp-activity/admin/css/admin.{$dev}css", array(), '20111203' ); 203 252 } 204 205 // Help panel - sidebar links206 get_current_screen()->set_help_sidebar(207 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .208 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'209 );210 253 211 254 // Handle spam/un-spam/delete of activities … … 343 386 $error = 0; 344 387 345 // Set tainted if a new form value is different from the object's old value346 $tainted = false;347 348 388 // Activity spam status 389 $prev_spam_status = $new_spam_status = false; 349 390 if ( ! empty( $_REQUEST['activity_status'] ) ) { 350 391 $prev_spam_status = $activity->is_spam; 351 $new_spam_status = ( 'spam' == $_REQUEST['activity_status'] ) ? 1 : 0;392 $new_spam_status = ( 'spam' == $_REQUEST['activity_status'] ) ? true : false; 352 393 } 353 394 354 395 // Activity action 355 if ( ! empty( $_REQUEST['bp-activities-action'] ) && stripslashes( $activity->action ) != stripslashes( $_REQUEST['bp-activities-action'] ) ) {396 if ( ! empty( $_REQUEST['bp-activities-action'] ) ) 356 397 $activity->action = $_REQUEST['bp-activities-action']; 357 $tainted = true;358 }359 398 360 399 // Activity content 361 if ( ! empty( $_REQUEST['bp-activities-content'] ) && stripslashes( $activity->content ) != stripslashes( $_REQUEST['bp-activities-content'] ) ) {400 if ( ! empty( $_REQUEST['bp-activities-content'] ) ) 362 401 $activity->content = $_REQUEST['bp-activities-content']; 363 $tainted = true; 402 403 // Activity primary link 404 if ( ! empty( $_REQUEST['bp-activities-link'] ) ) 405 $activity->primary_link = $_REQUEST['bp-activities-link']; 406 407 // Activity user ID 408 if ( ! empty( $_REQUEST['bp-activities-userid'] ) ) 409 $activity->user_id = (int) $_REQUEST['bp-activities-userid']; 410 411 // Activity item primary ID 412 if ( ! empty( $_REQUEST['bp-activities-primaryid'] ) ) 413 $activity->item_id = (int) $_REQUEST['bp-activities-primaryid']; 414 415 // Activity item secondary ID 416 if ( ! empty( $_REQUEST['bp-activities-secondaryid'] ) ) 417 $activity->secondary_item_id = (int) $_REQUEST['bp-activities-secondaryid']; 418 419 // Activity type 420 if ( ! empty( $_REQUEST['bp-activities-type'] ) ) { 421 $actions = array(); 422 423 // Walk through the registered actions, and build an array of actions/values. 424 foreach ( $bp->activity->actions as $action ) { 425 $action = array_values( (array) $action ); 426 427 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) 428 $actions[] = $action[$i]['key']; 429 } 430 431 // This was a mis-named activity type from before BP 1.6 432 unset( $actions['friends_register_activity_action'] ); 433 434 // Check that the new type is a registered activity type 435 if ( in_array( $_REQUEST['bp-activities-type'], $actions ) ) 436 $activity->type = $_REQUEST['bp-activities-type']; 364 437 } 365 438 … … 383 456 $gmt_date = get_gmt_from_date( sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ) ); 384 457 385 if ( $activity->date_recorded != $gmt_date ) { 386 $activity->date_recorded = $gmt_date; 387 $tainted = true; 388 } 458 $activity->date_recorded = $gmt_date; 389 459 } 390 460 391 461 // Has the spam status has changed? 392 if ( $ prev_spam_status != $new_spam_status ) {393 if ( 1 == $new_spam_status)462 if ( $new_spam_status != $prev_spam_status ) { 463 if ( $new_spam_status ) 394 464 bp_activity_mark_as_spam( $activity ); 395 465 else 396 466 bp_activity_mark_as_ham( $activity ); 397 398 $tainted = true;399 467 } 400 468 … … 406 474 407 475 // Check for any error during activity save 408 if ( ! $result && $tainted)476 if ( false === $result ) 409 477 $error = $activity->id; 410 478 … … 448 516 * Display the single activity edit screen 449 517 * 518 * @global int $screen_layout_columns Number of columns shown on this admin page 450 519 * @since 1.6 451 520 */ 452 521 function bp_activity_admin_edit() { 522 global $screen_layout_columns; 523 453 524 // @todo: Check if user is allowed to edit activity items 454 525 // if ( ! current_user_can( 'bp_edit_activity' ) ) … … 486 557 487 558 <form action="<?php echo esc_attr( $form_url ); ?>" id="bp-activities-edit-form" method="post"> 488 <div id="poststuff" class="metabox-holder has-right-sidebar">559 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>"> 489 560 <div id="side-info-column" class="inner-sidebar"> 490 561 <?php do_meta_boxes( 'toplevel_page_bp-activity', 'side', $activity ); ?> … … 574 645 575 646 /** 647 * Primary link metabox for the Activity admin edit screen 648 * 649 * @param object $item Activity item 650 * @since 1.6 651 */ 652 function bp_activity_admin_edit_metabox_link( $item ) { 653 ?> 654 655 <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label> 656 <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" /> 657 <p><?php _e( 'Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p> 658 659 <?php 660 } 661 662 /** 663 * User ID metabox for the Activity admin edit screen 664 * 665 * @param object $item Activity item 666 * @since 1.6 667 */ 668 function bp_activity_admin_edit_metabox_userid( $item ) { 669 ?> 670 671 <label class="screen-reader-text" for="bp-activities-userid"><?php _e( 'Author ID', 'buddypress' ); ?></label> 672 <input type="number" name="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" /> 673 674 <?php 675 } 676 677 /** 678 * Activity type metabox for the Activity admin edit screen 679 * 680 * @global object $bp BuddyPress global settings 681 * @param object $item Activity item 682 * @since 1.6 683 */ 684 function bp_activity_admin_edit_metabox_type( $item ) { 685 global $bp; 686 687 $actions = array(); 688 $selected = $item->type; 689 690 // Walk through the registered actions, and build an array of actions/values. 691 foreach ( $bp->activity->actions as $action ) { 692 $action = array_values( (array) $action ); 693 694 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) 695 $actions[ $action[$i]['key'] ] = $action[$i]['value']; 696 } 697 698 // This was a mis-named activity type from before BP 1.6 699 unset( $actions['friends_register_activity_action'] ); 700 701 // Sort array by the human-readable value 702 natsort( $actions ); 703 ?> 704 705 <select name="bp-activities-type"> 706 <?php foreach ( $actions as $k => $v ) : ?> 707 <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option> 708 <?php endforeach; ?> 709 </select> 710 711 <?php 712 } 713 714 /** 715 * Primary item ID/Secondary item ID metabox for the Activity admin edit screen 716 * 717 * @param object $item Activity item 718 * @since 1.6 719 */ 720 function bp_activity_admin_edit_metabox_itemids( $item ) { 721 ?> 722 723 <label for="bp-activities-primaryid"><?php _e( 'Primary Item ID', 'buddypress' ); ?></label> 724 <input type="number" name="bp-activities-primaryid" id="bp-activities-primaryid" value="<?php echo esc_attr( $item->item_id ); ?>" /> 725 <br /> 726 727 <label for="bp-activities-secondaryid"><?php _e( 'Secondary Item ID', 'buddypress' ); ?></label> 728 <input type="number" name="bp-activities-secondaryid" id="bp-activities-secondaryid" value="<?php echo esc_attr( $item->secondary_item_id ); ?>" /> 729 730 <p><?php _e( 'These identify the object that created this activity. For example, the fields could reference a pair of site and comment IDs.', 'buddypress' ); ?></p> 731 732 <?php 733 } 734 735 /** 576 736 * Display the Activity admin index screen, which contains a list of all the activities. 577 737 * … … 591 751 $spammed = !empty( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; 592 752 $unspammed = !empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; 593 $updated = !empty( $_REQUEST['updated'] )? (int) $_REQUEST['updated'] : 0;753 $updated = !empty( $_REQUEST['updated'] ) ? (int) $_REQUEST['updated'] : 0; 594 754 595 755 if ( $deleted > 0 ) … … 597 757 598 758 if ( $error > 0 ) 599 $messages[] = sprintf( __( 'An error occur ed when updating Activity ID #%s.', 'buddypress' ), number_format_i18n( $error ) );759 $messages[] = sprintf( __( 'An error occurred when updating Activity ID #%s.', 'buddypress' ), number_format_i18n( $error ) ); 600 760 601 761 if ( $spammed > 0 ) -
trunk/bp-activity/bp-activity-classes.php
r5262 r5484 87 87 $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam ); 88 88 89 if ( !$wpdb->query( $q ) )89 if ( false === $wpdb->query( $q ) ) 90 90 return false; 91 91
Note: See TracChangeset
for help on using the changeset viewer.