[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/question/classes/bank/ -> modifier_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 last modifier.
  22   *
  23   * @copyright  2009 Tim Hunt
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  class modifier_name_column extends column_base {
  27      public function get_name() {
  28          return 'modifiername';
  29      }
  30  
  31      protected function get_title() {
  32          return get_string('lastmodifiedby', 'question');
  33      }
  34  
  35      protected function display_content($question, $rowclasses) {
  36          if (!empty($question->modifierfirstname) && !empty($question->modifierlastname)) {
  37              $u = new \stdClass();
  38              $u = username_load_fields_from_object($u, $question, 'modifier');
  39              echo fullname($u);
  40          }
  41      }
  42  
  43      public function get_extra_joins() {
  44          return array('um' => 'LEFT JOIN {user} um ON um.id = q.modifiedby');
  45      }
  46  
  47      public function get_required_fields() {
  48          $allnames = get_all_user_name_fields();
  49          $requiredfields = array();
  50          foreach ($allnames as $allname) {
  51              $requiredfields[] = 'um.' . $allname . ' AS modifier' . $allname;
  52          }
  53          return $requiredfields;
  54      }
  55  
  56      public function is_sortable() {
  57          return array(
  58              'firstname' => array('field' => 'um.firstname', 'title' => get_string('firstname')),
  59              'lastname' => array('field' => 'um.lastname', 'title' => get_string('lastname')),
  60          );
  61      }
  62  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1