[ Index ]

PHP Cross Reference of moodle-2.8

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              echo fullname($u);
  41          }
  42      }
  43  
  44      public function get_extra_joins() {
  45          return array('uc' => 'LEFT JOIN {user} uc ON uc.id = q.createdby');
  46      }
  47  
  48      public function get_required_fields() {
  49          $allnames = get_all_user_name_fields();
  50          $requiredfields = array();
  51          foreach ($allnames as $allname) {
  52              $requiredfields[] = 'uc.' . $allname . ' AS creator' . $allname;
  53          }
  54          return $requiredfields;
  55      }
  56  
  57      public function is_sortable() {
  58          return array(
  59              'firstname' => array('field' => 'uc.firstname', 'title' => get_string('firstname')),
  60              'lastname' => array('field' => 'uc.lastname', 'title' => get_string('lastname')),
  61          );
  62      }
  63  }


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