Changeset 5528
- Timestamp:
- 12/12/2011 10:42:54 PM (14 years ago)
- Location:
- trunk/bp-activity
- Files:
-
- 3 edited
-
admin/css/admin.css (modified) (1 diff)
-
admin/css/admin.dev.css (modified) (1 diff)
-
bp-activity-admin.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/admin/css/admin.css
r5498 r5528 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;} #bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0;}#bp_activity_action h3,#bp_activity_content h3{cursor:auto;}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white;}#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;}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;}.activity-errors{list-style-type:disc;margin-left:2em;}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0;}#bp_activity_action h3,#bp_activity_content h3{cursor:auto;}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white;}#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
r5498 r5528 31 31 margin-top: 1px; 32 32 } 33 .activity-errors { 34 list-style-type: disc; 35 margin-left: 2em; 36 } 33 37 34 38 #bp_activity_action div.inside, -
trunk/bp-activity/bp-activity-admin.php
r5513 r5528 282 282 $deleted = $spammed = $unspammed = 0; 283 283 284 // Store any error that occurs when updating the database item285 $error = 0;284 // Store any errors that occurs when updating the database items 285 $errors = array(); 286 286 287 287 // "We'd like to shoot the monster, could you move, please?" … … 293 293 // Get the activity from the database 294 294 $activity = new BP_Activity_Activity( $activity_id ); 295 if ( empty( $activity->component ) ) 295 if ( empty( $activity->component ) ) { 296 $errors[] = $activity_id; 296 297 continue; 298 } 297 299 298 300 switch ( $doaction ) { … … 311 313 312 314 // Check for any error during activity save 313 if ( ! $result ) { 314 $error = $activity->id; 315 break; 316 } 317 318 $unspammed++; 315 if ( ! $result ) 316 $errors[] = $activity->id; 317 else 318 $unspammed++; 319 319 break; 320 320 … … 324 324 325 325 // Check for any error during activity save 326 if ( ! $result ) { 327 $error = $activity->id; 328 break; 329 } 330 331 $spammed++; 326 if ( ! $result ) 327 $errors[] = $activity->id; 328 else 329 $spammed++; 332 330 break; 333 331 … … 336 334 } 337 335 338 // If an error occured, don't bother looking at the other activities. Bail out of the foreach.339 if ( $error )340 break;341 342 336 // Release memory 343 337 unset( $activity ); … … 345 339 346 340 // Call actions for plugins to do something before we redirect 347 do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $error ), $redirect_to, $activity_ids );341 do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids ); 348 342 349 343 // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done. … … 358 352 359 353 // If an error occured, pass back the activity ID that failed 360 if ( $error)361 $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );354 if ( ! empty( $errors ) ) 355 $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to ); 362 356 363 357 // Redirect … … 769 763 // If the user has just made a change to an activity item, build status messages 770 764 if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) { 771 $deleted = !empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; 772 $error = !empty( $_REQUEST['error'] ) ? (int) $_REQUEST['error'] : 0; 773 $spammed = !empty( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; 774 $unspammed = !empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; 775 $updated = !empty( $_REQUEST['updated'] ) ? (int) $_REQUEST['updated'] : 0; 765 $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; 766 $errors = ! empty( $_REQUEST['error'] ) ? $_REQUEST['error'] : ''; 767 $spammed = ! empty( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; 768 $unspammed = ! empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; 769 $updated = ! empty( $_REQUEST['updated'] ) ? (int) $_REQUEST['updated'] : 0; 770 771 $errors = array_map( 'absint', explode( ',', $errors ) ); 776 772 777 773 if ( $deleted > 0 ) 778 774 $messages[] = sprintf( _n( '%s activity was permanently deleted.', '%s activities were permanently deleted.', $deleted, 'buddypress' ), number_format_i18n( $deleted ) ); 779 775 780 if ( $error > 0 ) 781 $messages[] = sprintf( __( 'An error occurred when updating Activity ID #%s.', 'buddypress' ), number_format_i18n( $error ) ); 776 if ( ! empty( $errors ) ) { 777 if ( 1 == count( $errors ) ) { 778 $error_msg = __( 'An error occurred when updating activity ID #%s.', 'buddypress' ); 779 780 } else { 781 $error_msg = __( 'Errors occurred when updating activity IDs:', 'buddypress' ); 782 $error_msg .= '<ul class="activity-errors">'; 783 784 // Display each error as a list item 785 foreach ( $errors as $error ) { 786 // Translators: This is a bulleted list of item IDs 787 $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>'; 788 } 789 790 $error_msg .= '</ul>'; 791 $messages[] = $error_msg; 792 } 793 } 782 794 783 795 if ( $spammed > 0 ) 784 $messages[] = sprintf( _n( '%s activity marked as spam.', '%s activitiesmarked as spam.', $spammed, 'buddypress' ), number_format_i18n( $spammed ) );796 $messages[] = sprintf( _n( '%s activity has been marked as spam.', '%s activities have been marked as spam.', $spammed, 'buddypress' ), number_format_i18n( $spammed ) ); 785 797 786 798 if ( $unspammed > 0 ) 787 $messages[] = sprintf( _n( '%s activity restored from the spam.', '%s activitiesrestored from the spam.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );799 $messages[] = sprintf( _n( '%s activity has been restored from the spam.', '%s activities have been restored from the spam.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) ); 788 800 789 801 if ( $updated > 0 ) … … 814 826 <?php // If the user has just made a change to an activity item, display the status messages ?> 815 827 <?php if ( !empty( $messages ) ) : ?> 816 <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error '] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>828 <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['errors'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div> 817 829 <?php endif; ?> 818 830
Note: See TracChangeset
for help on using the changeset viewer.