/totara/reportbuilder/embedded/rb_plan_programs_embedded.php

https://github.com/moodlehq/totara · PHP · 131 lines · 92 code · 14 blank · 25 comment · 5 complexity · 3a324d029da339d06188b22cb196851e MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of Totara LMS
  4. *
  5. * Copyright (C) 2010 - 2013 Totara Learning Solutions LTD
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @author Simon Coggins <simon.coggins@totaralms.com>
  21. * @package totara
  22. * @subpackage reportbuilder
  23. */
  24. require_once($CFG->dirroot . '/totara/program/lib.php');
  25. class rb_plan_programs_embedded extends rb_base_embedded {
  26. public $url, $source, $fullname, $filters, $columns;
  27. public $contentmode, $contentsettings, $embeddedparams;
  28. public $hidden, $accessmode, $accesssettings, $shortname;
  29. public function __construct($data) {
  30. $userid = array_key_exists('userid', $data) ? $data['userid'] : null;
  31. $rolstatus = array_key_exists('rolstatus', $data) ? $data['rolstatus'] : null;
  32. $exceptionstatus = array_key_exists('exceptionstatus', $data) ? $data['exceptionstatus'] : null;
  33. $this->url = '/totara/plan/record/programs.php';
  34. $this->source = 'dp_program';
  35. $this->shortname = 'plan_programs';
  36. $this->fullname = get_string('recordoflearningprograms', 'totara_plan');
  37. $this->columns = array(
  38. array(
  39. 'type' => 'program',
  40. 'value' => 'proglinkicon',
  41. 'heading' => get_string('programname', 'totara_program'),
  42. ),
  43. array(
  44. 'type' => 'program',
  45. 'value' => 'mandatory',
  46. 'heading' => get_string('mandatory', 'totara_program'),
  47. ),
  48. array(
  49. 'type' => 'program',
  50. 'value' => 'recurring',
  51. 'heading' => get_string('recurring', 'totara_program'),
  52. ),
  53. array(
  54. 'type' => 'program',
  55. 'value' => 'timedue',
  56. 'heading' => get_string('duestatus', 'totara_program'),
  57. ),
  58. array(
  59. 'type' => 'program_completion_history',
  60. 'value' => 'program_completion_history_link',
  61. 'heading' => get_string('program_completion_history_link', 'rb_source_dp_program'),
  62. ),
  63. array(
  64. 'type' => 'program_completion',
  65. 'value' => 'status',
  66. 'heading' => get_string('progress', 'totara_program'),
  67. ),
  68. );
  69. $this->filters = array(
  70. array(
  71. 'type' => 'program',
  72. 'value' => 'fullname',
  73. 'advanced' => 0,
  74. ),
  75. array(
  76. 'type' => 'course_category',
  77. 'value' => 'id',
  78. 'advanced' => 1,
  79. ),
  80. array(
  81. 'type' => 'program_completion_history',
  82. 'value' => 'program_completion_history_count',
  83. 'advanced' => 1,
  84. ),
  85. );
  86. // no restrictions
  87. $this->contentmode = REPORT_BUILDER_CONTENT_MODE_NONE;
  88. // don't include the front page (site-level course)
  89. $this->embeddedparams = array(
  90. 'category' => '!0',
  91. );
  92. if (isset($userid)) {
  93. $this->embeddedparams['userid'] = $userid;
  94. }
  95. if (isset($rolstatus)) {
  96. $this->embeddedparams['programstatus'] = null;
  97. switch ($rolstatus) {
  98. case 'active':
  99. $this->embeddedparams['programstatus'] = '!'.STATUS_PROGRAM_COMPLETE;
  100. break;
  101. case 'completed':
  102. $this->embeddedparams['programstatus'] = STATUS_PROGRAM_COMPLETE;
  103. break;
  104. }
  105. $this->embeddedparams['rolstatus'] = $rolstatus;
  106. }
  107. if (isset($exceptionstatus)) {
  108. $this->embeddedparams['exceptionstatus'] = $exceptionstatus;
  109. }
  110. $context = context_system::instance();
  111. if (!has_capability('totara/program:viewhiddenprograms', $context)) {
  112. // don't show hidden programs to non-admins
  113. $this->embeddedparams['visible'] = 1;
  114. }
  115. parent::__construct();
  116. }
  117. }