LLMS_Processor_Table_To_Csv::task( array $args )
Execute calculation for each item in the queue until all students in the course have been polled Stores the data in the postmeta table to be accessible via LLMS_Course
Description Description
Parameters Parameters
- $args
-
(array) (Required) query arguments passed to LLMS_Table
Return Return
(boolean) true to keep the item in the queue and process again false to remove the item from the queue
Source Source
File: includes/processors/class.llms.processor.table.to.csv.php
public function task( $args ) { $this->log( sprintf( 'csv generation task started for table %s', $args['_processor']['handler'] ) ); $this->log( $args ); $table = $this->get_handler( $args['_processor']['handler'] ); if ( ! $table ) { $this->log( sprintf( 'csv generation task failed for table %s (Handler not found)', $args['_processor']['handler'] ) ); return false; } $fh = @fopen( $args['_processor']['file'], 'a+' ); if ( ! $fh ) { $this->log( sprintf( 'csv generation task failed for table %s (file not opened)', $args['_processor']['handler'] ) ); return false; } // set the user to be the initiating user so the table will have the correct data wp_set_current_user( $args['_processor']['user_id'] ); $delimiter = apply_filters( 'llms_table_to_csv_processor_delimiter', ',', $this, $args ); $rows = $table->get_export( $args ); foreach ( $rows as $row ) { fputcsv( $fh, $row, $delimiter ); } fclose( $fh ); if ( $table->is_last_page() ) { $mailer = LLMS()->mailer()->get_email( 'table_to_csv' ); $mailer->add_recipient( $args['_processor']['user_id'] ); $mailer->add_attachment( $args['_processor']['file'] ); $mailer->set_subject( sprintf( esc_html__( 'Your %1$s export file from %2$s', 'lifterlms' ), $table->get_export_title( $args ), get_bloginfo( 'name' ) ) ); $mailer->set_body( __( 'Please find the attached CSV file.', 'lifterlms' ) ); // log when wp_mail fails if ( ! $mailer->send() ) { $this->log( sprintf( 'error sending csv email for table %s', $args['_processor']['handler'] ) ); } else { unlink( $args['_processor']['file'] ); } $this->_unlock_table( $table->get_export_lock_key() ); } return false; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.15.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: