ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSurveySyncTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2010 Leifos, GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5
15{
19 protected $access;
20
24 protected $tree;
25
33 public function __construct($a_parent_obj, $a_parent_cmd, SurveyQuestion $a_question)
34 {
35 global $DIC;
36
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 $this->access = $DIC->access();
40 $this->tree = $DIC->repositoryTree();
41 $ilCtrl = $DIC->ctrl();
42 $lng = $DIC->language();
43
44 $this->question = $a_question;
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->setId("il_svy_spl_sync");
49
50 $this->setTitle($this->question->getTitle());
51 $this->setDescription($lng->txt("survey_sync_question_copies_info"));
52
53 $this->addCommandButton("synccopies", $lng->txt("survey_sync_question_copies"));
54 $this->addCommandButton("cancelsync", $lng->txt("cancel"));
55
56 // $this->setSelectAllCheckbox("id[]");
57 $this->addColumn("", "", 1);
58 $this->addColumn($lng->txt("title"), "");
59
60 $this->setDefaultOrderField("title");
61 $this->setDefaultOrderDirection("asc");
62
63 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
64 $this->setRowTemplate("tpl.il_svy_qpl_sync.html", "Modules/SurveyQuestionPool");
65
66 $this->importData();
67 }
68
72 protected function importData()
73 {
74 $ilAccess = $this->access;
76
77 include_once "Modules/Survey/classes/class.ilObjSurvey.php";
78
79 $table_data = array();
80 foreach ($this->question->getCopyIds(true) as $survey_obj_id => $questions) {
81 $survey_id = new ilObjSurvey($survey_obj_id, false);
82 $survey_id->loadFromDB();
83 $survey_id = $survey_id->getSurveyId();
84
85 $ref_ids = ilObject::_getAllReferences($survey_obj_id);
86 $message = "";
87
88 // check permissions for "parent" survey
89 $can_write = false;
90 if (!ilObjSurvey::_hasDatasets($survey_id)) {
91 foreach ($ref_ids as $ref_id) {
92 if ($ilAccess->checkAccess("edit", "", $ref_id)) {
93 $can_write = true;
94 break;
95 }
96 }
97
98 if (!$can_write) {
99 $message = $lng->txt("survey_sync_insufficient_permissions");
100 }
101 } else {
102 $message = $lng->txt("survey_has_datasets_warning");
103 }
104
105 $survey_title = ilObject::_lookupTitle($survey_obj_id);
106 $survey_path = $this->buildPath($ref_ids);
107
108 foreach ($questions as $question_id) {
109 $title = SurveyQuestion::_getTitle($question_id);
110
111 if (!$can_write) {
112 $question_id = null;
113 }
114
115 $table_data[] = array(
116 "id" => $question_id,
117 "title" => $title,
118 "path" => $survey_path,
119 "message" => $message
120 );
121 }
122 }
123
124 $this->setData($table_data);
125 }
126
132 protected function fillRow($a_set)
133 {
136
137 $this->tpl->setVariable("TXT_PATH", $lng->txt("path"));
138
139 if ($a_set["message"]) {
140 $this->tpl->setCurrentBlock("message");
141 $this->tpl->setVariable("TXT_MESSAGE", $a_set["message"]);
142 $this->tpl->parseCurrentBlock();
143 }
144
145 // question
146 if ($a_set["id"]) {
147 $this->tpl->setCurrentBlock("checkbox");
148 $this->tpl->setVariable("ID", $a_set["id"]);
149 $this->tpl->parseCurrentBlock();
150 }
151
152
153 $this->tpl->setVariable("TITLE", $a_set["title"]);
154 $this->tpl->setVariable("VALUE_PATH", implode("<br />", $a_set["path"]));
155 }
156
163 protected function buildPath($ref_ids)
164 {
167
168 include_once './Services/Link/classes/class.ilLink.php';
169
170 if (!count($ref_ids)) {
171 return false;
172 }
173 foreach ($ref_ids as $ref_id) {
174 $path = "...";
175
176 $counter = 0;
177 $path_full = $tree->getPathFull($ref_id);
178 if (sizeof($path_full)) {
179 foreach ($path_full as $data) {
180 if (++$counter < (count($path_full) - 1)) {
181 continue;
182 }
183 $path .= " &raquo; ";
184 if ($ref_id != $data['ref_id']) {
185 $path .= $data['title'];
186 } else {
187 $path .= ('<a target="_top" href="' .
188 ilLink::_getLink($data['ref_id'], $data['type']) . '">' .
189 $data['title'] . '</a>');
190 }
191 }
192 }
193
194 $result[] = $path;
195 }
196 return $result;
197 }
198}
$result
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
Basic class for all survey question types.
static _getTitle($question_id)
Returns the question title of a question with a given id.
static _hasDatasets($survey_id)
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
Survey sync table GUI class.
fillRow($a_set)
Fill table row.
buildPath($ref_ids)
Build path with deep-link.
__construct($a_parent_obj, $a_parent_cmd, SurveyQuestion $a_question)
Constructor.
importData()
Import data from DB.
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setDescription($a_val)
Set description.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
global $ilCtrl
Definition: ilias.php:18
catch(Exception $e) $message
global $DIC
Definition: saml.php:7