4 include_once(
"Services/Table/classes/class.ilTable2GUI.php");
29 public function __construct($a_parent_obj, $a_parent_cmd =
"", $a_parent_ref_id,
ilBadge $a_award_bagde = null, $a_parent_obj_id = null, $a_restrict_badge_id = null)
33 $this->ctrl = $DIC->ctrl();
34 $this->lng = $DIC->language();
35 $this->tree = $DIC->repositoryTree();
37 $lng = $DIC->language();
39 $this->
setId(
"bdgusr");
40 $this->award_badge = $a_award_bagde;
41 $this->do_parent =
false;
44 if (in_array($parent_type, array(
"grp",
"crs"))) {
48 parent::__construct($a_parent_obj, $a_parent_cmd);
52 if ($this->award_badge) {
53 $this->
setTitle(
$lng->txt(
"badge_award_badge") .
": " . $a_award_bagde->getTitle());
63 if ($a_parent_obj_id) {
66 include_once
"Services/Object/classes/class.ilObjectDataDeletionLog.php";
72 if ($a_restrict_badge_id) {
73 include_once(
"Services/Badge/classes/class.ilBadge.php");
74 $badge =
new ilBadge($a_restrict_badge_id);
75 $title .=
" - " . $badge->getTitle();
88 if ($this->do_parent) {
102 $this->
getItems($a_parent_ref_id, $this->award_badge, $a_parent_obj_id, $a_restrict_badge_id);
110 $this->filter[
"name"] =
$name->getValue();
113 public function getItems($a_parent_ref_id,
ilBadge $a_award_bagde = null, $a_parent_obj_id = null, $a_restrict_badge_id = null)
119 if (!$a_parent_obj_id) {
124 if ($a_parent_ref_id) {
128 $obj_ids = array($a_parent_obj_id);
131 if ($this->do_parent) {
132 foreach (
$tree->getSubTree(
$tree->getNodeData($a_parent_ref_id)) as $node) {
133 $obj_ids[] = $node[
"obj_id"];
137 include_once
"Services/Badge/classes/class.ilBadge.php";
138 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
139 $badges = $assignments = array();
140 foreach ($obj_ids as $obj_id) {
142 $badges[$badge->getId()] = $badge;
146 if ($a_restrict_badge_id &&
147 $a_restrict_badge_id != $ass->getBadgeId()) {
152 if ($this->award_badge &&
153 $ass->getBadgeId() != $this->award_badge->getId()) {
157 $assignments[$ass->getUserId()][] = $ass;
163 $user_ids = array_keys($assignments);
166 include_once
"Services/Badge/classes/class.ilBadgeRenderer.php";
167 include_once
"Services/User/classes/class.ilUserQuery.php";
168 $tmp[
"set"] = array();
169 if (count($user_ids) > 0) {
171 $uquery->setLimit(9999);
172 $uquery->setUserFilter($user_ids);
174 if ($this->filter[
"name"]) {
175 $uquery->setTextFilter($this->filter[
"name"]);
178 $tmp = $uquery->query();
180 foreach ($tmp[
"set"] as
$user) {
182 if (array_key_exists($user[
"usr_id"], $assignments)) {
183 foreach ($assignments[$user[
"usr_id"]] as $user_ass) {
184 $idx = $user_ass->getBadgeId() .
"-" . $user[
"usr_id"];
186 $badge = $badges[$user_ass->getBadgeId()];
188 if ($this->do_parent) {
189 $parent = $badge->getParentMeta();
193 "user_id" => $user[
"usr_id"],
194 "name" => $user[
"lastname"] .
", " . $user[
"firstname"],
195 "login" => $user[
"login"],
197 "title" => $badge->getTitle(),
198 "issued" => $user_ass->getTimestamp(),
199 "parent_id" => $parent[
"id"],
200 "parent_meta" => $parent
205 elseif ($this->award_badge) {
206 $idx =
"0-" . $user[
"usr_id"];
209 "user_id" => $user[
"usr_id"],
210 "name" => $user[
"lastname"] .
", " . $user[
"firstname"],
211 "login" => $user[
"login"],
227 if ($this->award_badge) {
228 $this->tpl->setVariable(
"VAL_ID", $a_set[
"user_id"]);
231 $this->tpl->setVariable(
"TXT_NAME", $a_set[
"name"]);
232 $this->tpl->setVariable(
"TXT_LOGIN", $a_set[
"login"]);
233 $this->tpl->setVariable(
"TXT_TYPE", $a_set[
"type"]);
234 $this->tpl->setVariable(
"TXT_TITLE", $a_set[
"title"]);
235 $this->tpl->setVariable(
"TXT_ISSUED", $a_set[
"issued"]
239 if ($a_set[
"parent_id"]) {
240 $parent = $a_set[
"parent_meta"];
241 $this->tpl->setVariable(
"PARENT", $parent[
"title"]);
242 $this->tpl->setVariable(
"PARENT_TYPE",
$lng->txt(
"obj_" . $parent[
"type"]));
243 $this->tpl->setVariable(
245 ilObject::_getIcon($parent[
"id"],
"big", $parent[
"type"])
setDescription($a_val)
Set description.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
static _lookupTitle($a_id)
lookup object title
getParentCmd()
Get parent command.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getItems($a_parent_ref_id, ilBadge $a_award_bagde=null, $a_parent_obj_id=null, $a_restrict_badge_id=null)
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static getInstancesByParentId($a_parent_id, array $a_filter=null)
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
static getExtendedTypeCaption(ilBadgeType $a_type)
static _lookupObjId($a_id)
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
__construct($a_parent_obj, $a_parent_cmd="", $a_parent_ref_id, ilBadge $a_award_bagde=null, $a_parent_obj_id=null, $a_restrict_badge_id=null)
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.
TableGUI class for badge user listing.
setLimit($a_limit=0, $a_default_limit=0)
static getInstance()
Constructor.
static getInstancesByParentId($a_parent_obj_id)
setFilterCommand($a_val, $a_caption=null)
Set filter command.