[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/things/ -> note.php (source)

   1  <?php
   2  /**
   3   * Things: GP_Note class
   4   *
   5   * @package GlotPress
   6   * @subpackage Things
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Core class used to implement the notes system.
  12   *
  13   * @since 3.0.0
  14   */
  15  class GP_Note extends GP_Thing {
  16  
  17      /**
  18       * Name of the database table.
  19       *
  20       * @var string $table_basename
  21       */
  22      public $table_basename = 'gp_notes';
  23  
  24      /**
  25       * List of field names for a translation.
  26       *
  27       * @var array $field_names
  28       */
  29      public $field_names = array(
  30          'id',
  31          'original_id',
  32          'translation_id',
  33          'note',
  34          'user_id',
  35          'date_added',
  36          'date_modified',
  37      );
  38  
  39      /**
  40       * List of field names which have an integer value.
  41       *
  42       * @var array $int_fields
  43       */
  44      public $int_fields = array(
  45          'id',
  46          'original_id',
  47          'translation_id',
  48          'user_id',
  49      );
  50  
  51      /**
  52       * List of field names which cannot be updated.
  53       *
  54       * @var array $non_updatable_attributes
  55       */
  56      public $non_updatable_attributes = array( 'id' );
  57  
  58      /**
  59       * SQL string for order by date
  60       *
  61       * @var array $default_order
  62       */
  63      public $default_order = 'ORDER BY date_added DESC';
  64  
  65      /**
  66       * Save the note
  67       *
  68       * @since 3.0.0
  69       *
  70       * @param string $args    Parameters that are not used.
  71       *
  72       * @return object The output of the query.
  73       */
  74  	public function save( $args = null ) {
  75          $original_id    = gp_post( 'original_id' );
  76          $translation_id = gp_post( 'translation_id' );
  77          $note           = trim( esc_html( gp_post( 'note' ) ) );
  78  
  79          return $this->create_and_select(
  80              array(
  81                  'original_id'    => $original_id,
  82                  'translation_id' => $translation_id,
  83                  'note'           => $note,
  84                  'user_id'        => get_current_user_id(),
  85              )
  86          );
  87      }
  88  
  89      /**
  90       * Edit the note
  91       *
  92       * @since 3.0.0
  93       *
  94       * @param string $note_id     Note ID.
  95       * @param string $note        Note object.
  96       * @param string $translation Translation object.
  97       *
  98       * @return object The output of the query.
  99       */
 100  	public function edit( $note_id, $note, $translation ) {
 101          $note_object = GP::$notes->get( $note_id );
 102  
 103          $this->update( array( 'note' => $note ), array( 'id' => $note_id ) );
 104  
 105          return $this->get( $note_id );
 106      }
 107  
 108      /**
 109       * Retrieves the note for this translation id.
 110       *
 111       * @since 3.0.0
 112       *
 113       * @param object $translation_id The translation id.
 114       * @param object $order The note order.
 115       *
 116       * @return array notes
 117       */
 118  	public function get_by_translation_id( $translation_id, $order = null ) {
 119          return $this->many(
 120              $this->select_all_from_conditions_and_order(
 121                  array(
 122                      'translation_id' => $translation_id,
 123                  ),
 124                  $order
 125              )
 126          );
 127      }
 128  }
 129  
 130  GP::$notes = new GP_Note();


Generated: Wed Nov 20 01:01:59 2019 Cross-referenced by PHPXref 0.7.1