ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMDCopyrightUsageTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
15 protected $copyright_id;
16
20 protected $db;
21
22 protected $lng;
23
24 protected $filter;
25 protected $objects;
26
32 public function __construct($a_parent_obj, $a_parent_cmd = '')
33 {
34 global $DIC;
35
36 $this->db = $DIC->database();
37 $this->copyright_id = $a_parent_obj->getEntryId();
38 $this->lng = $DIC->language();
39 $this->lng->loadLanguageModule('meta');
40
41 $this->setId("mdcopusage" . $this->copyright_id);
42 parent::__construct($a_parent_obj, $a_parent_cmd);
43 }
44
45
49 public function init()
50 {
51 $md_entry = new ilMDCopyrightSelectionEntry($this->copyright_id);
52 $this->setTitle($md_entry->getTitle());
53
54 $this->addColumn($this->lng->txt('object'), 'object');
55 $this->addColumn($this->lng->txt('meta_references'), 'references');
56 $this->addColumn($this->lng->txt('meta_copyright_sub_items'), 'subitems');
57 $this->addColumn($this->lng->txt('owner'), 'owner');
58
59 $this->setRowTemplate("tpl.show_copyright_usages_row.html", "Services/MetaData");
60 $this->setFormAction($this->ctrl->getFormAction(
61 $this->getParentObject(),
62 $this->getParentCmd()
63 ));
64 $this->setDisableFilterHiding(true);
65
66 $this->initFilter();
67 }
68
72 public function parse()
73 {
74 $data = $this->collectData($this->getCurrentFilter());
75 $this->setData($data);
76 }
77
81 public function initFilter()
82 {
84 "title",
86 false,
87 $this->lng->txt("object") . " " . $this->lng->txt("title")
88 );
89 $this->filter["title"] = $title->getValue();
90
91 //object
92 $this->objects = array();
93 foreach ($this->getObjTypesAvailable() as $item) {
94 $this->objects[$item] = $this->lng->txt("obj_" . $item);
95 }
97 $item->setOptions(array("" => "-") + $this->objects);
98 $this->filter["object"] = $item->getValue();
99 }
100
105 protected function getCurrentFilter()
106 {
107 $filter = array();
108 if ($this->filter["title"]) {
109 $filter["title"] = $this->filter["title"];
110 }
111
112 if ($this->filter['object']) {
113 $filter['object'] = $this->filter['object'];
114 }
115 return $filter;
116 }
117
118 public function fillRow($a_set)
119 {
120 global $DIC;
121
122 $f = $DIC->ui()->factory();
123 $r = $DIC->ui()->renderer();
124
125 $icon = $f->symbol()->icon()->standard($a_set['type'], $this->lng->txt($a_set['type']), "medium");
126 $this->tpl->setVariable('OBJ_TYPE_ICON', $r->render($icon));
127 $this->tpl->setVariable('TITLE', $a_set['title']);
128 $this->tpl->setVariable("DESCRIPTION", $a_set['desc']);
129 if ($a_set['references']) {
130 $path = new ilPathGUI();
131 $path->enableHideLeaf(false);
132 $path->enableDisplayCut(true);
133 $path->enableTextOnly(false);
134
135 foreach ($a_set['references'] as $reference) {
136 $this->tpl->setCurrentBlock("references");
137 $this->tpl->setVariable("REFERENCE", $path->getPath(ROOT_FOLDER_ID, $reference));
138 $this->tpl->parseCurrentBlock();
139 }
140 }
141
142 $this->tpl->setVariable('SUB_ITEMS', $a_set['sub_items']);
143
144 //TODO FIX WHITE PAGE OWNER LINK
145 if ($a_set['owner_link']) {
146 $this->tpl->setCurrentBlock("link_owner");
147 $this->tpl->setVariable("OWNER_LINK", $a_set['owner_link']);
148 $this->tpl->setVariable('OWNER', $a_set['owner_name']);
149 $this->tpl->parseCurrentBlock();
150 } else {
151 $this->tpl->setCurrentBlock("owner");
152 $this->tpl->setVariable('OWNER', $a_set['owner_name']);
153 $this->tpl->parseCurrentBlock();
154 }
155 }
156
161 public function collectData(array $filters)
162 {
163 $db_data = $this->getDataFromDB();
164
165 $data = array();
166 foreach ($db_data as $item) {
167 $obj_id = $item['obj_id'];
168 if ($filters['title']) {
169 if (stripos(ilObject::_lookupTitle($obj_id), $filters['title']) === false) {
170 continue;
171 }
172 }
173 if ($filters['object']) {
174 if (ilObject::_lookupType($obj_id) != $filters['object']) {
175 continue;
176 }
177 }
178 $data[] = array(
179 "obj_id" => $obj_id,
180 "type" => ilObject::_lookupType($obj_id),
181 "title" => ilObject::_lookupTitle($obj_id),
182 "desc" => ilObject::_lookupDescription($obj_id),
183 "references" => ilObject::_getAllReferences($obj_id),
185 "owner_link" => ilUserUtil::getProfileLink(ilObject::_lookupOwner($obj_id)),
186 "sub_items" => $this->getCountSubItemsFromDB($obj_id)
187 );
188 }
189
190 return $data;
191 }
192
193 public function getObjTypesAvailable()
194 {
195 $query = "SELECT DISTINCT obj_type FROM il_meta_rights " .
196 "WHERE description = " . $this->db->quote('il_copyright_entry__' . IL_INST_ID . '__' . $this->copyright_id, 'text') .
197 " AND rbac_id = obj_id";
198 $result = $this->db->query($query);
199 $data = array();
200 while ($row = $this->db->fetchAssoc($result)) {
201 array_push($data, $row['obj_type']);
202 }
203 return $data;
204 }
205
209 public function getDataFromDB()
210 {
211 $query = "SELECT rbac_id, obj_id, obj_type FROM il_meta_rights " .
212 "WHERE description = " . $this->db->quote('il_copyright_entry__' . IL_INST_ID . '__' . $this->copyright_id, 'text') .
213 ' AND rbac_id != ' . $this->db->quote(0, 'integer') .
214 " GROUP BY rbac_id";
215
216 $result = $this->db->query($query);
217 $data = array();
218 while ($row = $this->db->fetchAssoc($result)) {
219 $data[] = array(
220 "obj_id" => $row['rbac_id'],
221 "obj_type" => $row['obj_type']
222 );
223 }
224 return $data;
225 }
226
227 public function getCountSubItemsFromDB($a_rbac_id)
228 {
229 $query = "SELECT count(rbac_id) total FROM il_meta_rights " .
230 "WHERE rbac_id = " . $this->db->quote($a_rbac_id) .
231 " AND rbac_id <> obj_id";
232
233 $result = $this->db->query($query);
234 $row = $this->db->fetchAssoc($result);
235
236 return $row['total'];
237 }
238}
$result
An exception for terminatinating execution or to throw for unit testing.
getCurrentFilter()
Get current filter settings.
fillRow($a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd='')
ilCopyrightUsageGUI constructor.
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
static _getAllReferences($a_id)
get all reference ids of object
static _lookupOwner($a_id)
lookup object owner
static _lookupType($a_id, $a_reference=false)
lookup object type
Creates a path for a start and endnode.
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
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.
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.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getProfileLink($a_usr_id)
Get link to personal profile Return empty string in case of not public profile.
const IL_INST_ID
Definition: constants.php:38
const ROOT_FOLDER_ID
Definition: constants.php:30
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query