| 1 | <?php |
| 2 | /** |
| 3 | * This plugin stores discared warnings into a database table. |
| 4 | * |
| 5 | * @author Dominik Schilling (ocean90) |
| 6 | */ |
| 7 | class GP_WPorg_Log_Discarded_Warnings extends GP_Plugin { |
| 8 | var $id = 'wporg-log-discarded-warnings'; |
| 9 | |
| 10 | /** |
| 11 | * Holds the table name for storing warnings. |
| 12 | * |
| 13 | * @var string |
| 14 | */ |
| 15 | var $table_name = 'translate-warnings'; |
| 16 | |
| 17 | function __construct() { |
| 18 | parent::__construct(); |
| 19 | $this->add_action( 'warning_discarded', array( 'args' => 5 ) ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Stores discared warnings into a table. |
| 24 | * |
| 25 | * @param int $project_id ID of the project. |
| 26 | * @param int $translation_set ID if the translation set. |
| 27 | * @param int $translation ID of the translation. |
| 28 | * @param string $warning Key of the warning. (length, tags, placeholders, both_begin_end_on_newlines) |
| 29 | * @param int $user ID of the user. |
| 30 | */ |
| 31 | function warning_discarded( $project_id, $translation_set, $translation, $warning, $user ) { |
| 32 | global $gpdb; |
| 33 | |
| 34 | $warning = array( |
| 35 | 'project_id' => $project_id, |
| 36 | 'translation_set' => $translation_set, |
| 37 | 'translation' => $translation, |
| 38 | 'warning' => $warning, |
| 39 | 'user' => $user, |
| 40 | 'status' => 'needs-review' |
| 41 | ); |
| 42 | $format = array( '%d', '%d', '%d', '%s', '%d', '%s' ); |
| 43 | $gpdb->insert( |
| 44 | $this->table_name, |
| 45 | $warning, |
| 46 | $format |
| 47 | ); |
| 48 | } |
| 49 | } |
| 50 | GP::$plugins->wporg_log_discared_warnings = new GP_WPorg_Log_Discarded_Warnings; |