[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/classes/bank/ -> creator_name_column.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  
  18  namespace core_question\bank;
  19  
  20  /**
  21   * A column type for the name of the question creator.
  22   *
  23   * @copyright  2009 Tim Hunt
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  class creator_name_column extends column_base {
  28      public function get_name() {
  29          return 'creatorname';
  30      }
  31  
  32      protected function get_title() {
  33          return get_string('createdby', 'question');
  34      }
  35  
  36      protected function display_content($question, $rowclasses) {
  37          if (!empty($question->creatorfirstname) && !empty($question->creatorlastname)) {
  38              $u = new \stdClass();
  39              $u = username_load_fields_from_object($u, $question, 'creator');
  40              $date = userdate($question->timecreated, get_string('strftimedatetime', 'langconfig'));
  41              echo fullname($u) . '<br>' . \html_writer::tag('span', $date, array('class' => 'date'));
  42          }
  43      }
  44  
  45      public function get_extra_joins() {
  46          return array('uc' => 'LEFT JOIN {user} uc ON uc.id = q.createdby');
  47      }
  48  
  49      public function get_required_fields() {
  50          $allnames = get_all_user_name_fields();
  51          $requiredfields = array();
  52          foreach ($allnames as $allname) {
  53              $requiredfields[] = 'uc.' . $allname . ' AS creator' . $allname;
  54          }
  55          $requiredfields[] = 'q.timecreated';
  56          return $requiredfields;
  57      }
  58  
  59      public function is_sortable() {
  60          return array(
  61              'firstname' => array('field' => 'uc.firstname', 'title' => get_string('firstname')),
  62              'lastname' => array('field' => 'uc.lastname', 'title' => get_string('lastname')),
  63              'timecreated' => array('field' => 'q.timecreated', 'title' => get_string('date'))
  64          );
  65      }
  66  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1