3 include_once(
"./Services/Badge/classes/class.ilBadgeHandler.php");
30 public function __construct($a_parent_ref_id, $a_parent_obj_id = null, $a_parent_obj_type = null)
34 $this->parent_ref_id = $a_parent_ref_id;
35 $this->parent_obj_id = $a_parent_obj_id
38 $this->parent_obj_type = $a_parent_obj_type
47 $lng->loadLanguageModule(
"badge");
54 $next_class = $ilCtrl->getNextClass($this);
55 $cmd = $ilCtrl->getCmd(
"listBadges");
59 case "ilpropertyformgui":
61 if((
int)$_REQUEST[
"bid"])
63 include_once
"./Services/Badge/classes/class.ilBadge.php";
64 $badge =
new ilBadge((
int)$_REQUEST[
"bid"]);
65 $type = $badge->getTypeInstance();
66 $form = $this->
initBadgeForm(
"edit", $type, $badge->getTypeId());
71 $type_id = $_REQUEST[
"type"];
72 $ilCtrl->setParameter($this,
"type", $type_id);
74 $type = $handler->getTypeInstanceByUniqueId($type_id);
77 $ilCtrl->forwardCommand($form);
113 $ilTabs->addSubTab(
"badges",
114 $lng->txt(
"obj_bdga"),
115 $ilCtrl->getLinkTarget($this,
"listBadges"));
117 $ilTabs->addSubTab(
"users",
119 $ilCtrl->getLinkTarget($this,
"listUsers"));
121 $ilTabs->activateSubTab($a_active);
127 return $ilAccess->checkAccess(
"write",
"", $this->parent_ref_id);
139 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
142 include_once
"Services/Badge/classes/class.ilBadge.php";
144 foreach($valid_types as $id => $type)
146 $options[$id] = ($this->parent_obj_type !=
"bdga")
148 : $type->getCaption();
152 include_once
"Services/Form/classes/class.ilSelectInputGUI.php";
155 $ilToolbar->addInputItem($drop,
true);
157 $ilToolbar->setFormAction($ilCtrl->getFormAction($this,
"addBadge"));
158 $ilToolbar->addFormButton($lng->txt(
"create"),
"addBadge");
165 if(is_array(
$_SESSION[self::CLIPBOARD_ID]))
169 $ilToolbar->addSeparator();
175 $tt[] = $badge->getTitle();
178 include_once
"Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
181 implode(
"<br />", $tt),
188 $lng->loadLanguageModule(
"content");
189 $ilToolbar->addButton($lng->txt(
"cont_paste_from_clipboard").
190 " (".sizeof($tt).
")",
191 $ilCtrl->getLinkTarget($this,
"pasteBadges"),
193 $ilToolbar->addButton($lng->txt(
"clear_clipboard"),
194 $ilCtrl->getLinkTarget($this,
"clearClipboard"));
198 include_once
"Services/Badge/classes/class.ilBadgeTableGUI.php";
200 $tpl->setContent(
$tbl->getHTML());
205 include_once
"Services/Badge/classes/class.ilBadgeTableGUI.php";
208 $tbl->writeFilterToSession();
214 include_once
"Services/Badge/classes/class.ilBadgeTableGUI.php";
230 $type_id = $_REQUEST[
"type"];
234 $ilCtrl->redirect($this,
"listBadges");
237 $ilCtrl->setParameter($this,
"type", $type_id);
240 $type = $handler->getTypeInstanceByUniqueId($type_id);
243 $ilCtrl->redirect($this,
"listBadges");
251 $tpl->setContent($a_form->getHTML());
258 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
260 $form->setFormAction($ilCtrl->getFormAction($this,
"saveBadge"));
261 $form->setTitle($lng->txt(
"badge_badge").
' "'.$a_type->
getCaption().
'"');
264 $form->addItem($active);
267 $title->setRequired(
true);
272 $form->addItem($desc);
276 $form->addItem($crit);
278 if($a_mode ==
"create")
284 $form->addItem($img_mode);
286 $img_mode_tmpl =
new ilRadioOption($lng->txt(
"badge_image_from_template"),
"tmpl");
287 $img_mode->addOption($img_mode_tmpl);
289 $img_mode_up =
new ilRadioOption($lng->txt(
"badge_image_from_upload"),
"up");
290 $img_mode->addOption($img_mode_up);
294 $img_upload->setSuffixes(
array(
"png",
"svg"));
295 $img_mode_up->addSubItem($img_upload);
299 include_once
"Services/Badge/classes/class.ilBadgeImageTemplate.php";
301 if(
sizeof($valid_templates))
304 $options[
""] = $lng->txt(
"please_select");
305 foreach($valid_templates as $tmpl)
307 $options[$tmpl->getId()] = $tmpl->getTitle();
310 $tmpl =
new ilSelectInputGUI($lng->txt(
"badge_image_template_form"),
"tmpl");
313 $img_mode_tmpl->addSubItem($tmpl);
318 $img_mode_tmpl->setDisabled(
true);
319 $img_mode->setValue(
"up");
326 $img_upload->setALlowDeletion(
false);
327 $form->addItem($img_upload);
337 $custom->initConfigForm($form, $this->parent_ref_id);
342 if($a_mode ==
"create")
344 $form->addCommandButton(
"saveBadge", $lng->txt(
"save"));
348 $form->addCommandButton(
"updateBadge", $lng->txt(
"save"));
350 $form->addCommandButton(
"listBadges", $lng->txt(
"cancel"));
359 $type_id = $_REQUEST[
"type"];
363 $ilCtrl->redirect($this,
"listBadges");
366 $ilCtrl->setParameter($this,
"type", $type_id);
369 $type = $handler->getTypeInstanceByUniqueId($type_id);
372 $ilCtrl->redirect($this,
"listBadges");
376 $custom = $type->getConfigGUIInstance();
378 if($form->checkInput() &&
379 (!$custom || $custom->validateForm($form)))
381 include_once
"Services/Badge/classes/class.ilBadge.php";
383 $badge->setParentId($this->parent_obj_id);
384 $badge->setTypeId($type_id);
385 $badge->setActive($form->getInput(
"act"));
386 $badge->setTitle($form->getInput(
"title"));
387 $badge->setDescription($form->getInput(
"desc"));
388 $badge->setCriteria($form->getInput(
"crit"));
389 $badge->setValid($form->getInput(
"valid"));
394 $badge->setConfiguration($custom->getConfigFromForm($form));
399 if($form->getInput(
"img_mode") ==
"up")
401 $badge->uploadImage($_FILES[
"img"]);
406 $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
410 $ilCtrl->redirect($this,
"listBadges");
413 $form->setValuesByPost();
421 $badge_id = $_REQUEST[
"bid"];
425 $ilCtrl->redirect($this,
"listBadges");
428 $ilCtrl->setParameter($this,
"bid", $badge_id);
430 include_once
"./Services/Badge/classes/class.ilBadge.php";
431 $badge =
new ilBadge($badge_id);
436 ilUtil::sendInfo(sprintf($lng->txt(
"badge_edit_with_published"), $static_cnt));
441 $type = $badge->getTypeInstance();
442 $a_form = $this->
initBadgeForm(
"edit", $type, $badge->getTypeId());
446 $tpl->setContent($a_form->getHTML());
471 $badge_id = $_REQUEST[
"bid"];
475 $ilCtrl->redirect($this,
"listBadges");
478 $ilCtrl->setParameter($this,
"bid", $badge_id);
480 include_once
"./Services/Badge/classes/class.ilBadge.php";
481 $badge =
new ilBadge($badge_id);
482 $type = $badge->getTypeInstance();
483 $custom = $type->getConfigGUIInstance();
489 $form = $this->
initBadgeForm(
"update", $type, $badge->getTypeId());
490 if($form->checkInput() &&
491 (!$custom || $custom->validateForm($form)))
493 $badge->setActive($form->getInput(
"act"));
494 $badge->setTitle($form->getInput(
"title"));
495 $badge->setDescription($form->getInput(
"desc"));
496 $badge->setCriteria($form->getInput(
"crit"));
497 $badge->setValid($form->getInput(
"valid"));
501 $badge->setConfiguration($custom->getConfigFromForm($form));
506 $badge->uploadImage($_FILES[
"img"]);
509 $ilCtrl->redirect($this,
"listBadges");
513 $form->setValuesByPost();
523 $ilTabs->clearTargets();
524 $ilTabs->setBackTarget($lng->txt(
"back"),
525 $ilCtrl->getLinkTarget($this,
"listBadges"));
527 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
529 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
530 $confirmation_gui->setHeaderText($lng->txt(
"badge_deletion_confirmation"));
531 $confirmation_gui->setCancel($lng->txt(
"cancel"),
"listBadges");
532 $confirmation_gui->setConfirm($lng->txt(
"delete"),
"deleteBadges");
534 include_once
"Services/Badge/classes/class.ilBadge.php";
535 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
536 foreach($badge_ids as $badge_id)
538 $badge =
new ilBadge($badge_id);
539 $confirmation_gui->addItem(
"id[]", $badge_id, $badge->getTitle().
543 $tpl->setContent($confirmation_gui->getHTML());
552 include_once
"Services/Badge/classes/class.ilBadge.php";
553 foreach($badge_ids as $badge_id)
555 $badge =
new ilBadge($badge_id);
560 $ilCtrl->redirect($this,
"listBadges");
572 $badge_ids = $_REQUEST[
"id"];
576 $ilCtrl->redirect($this,
"listBadges");
588 $_SESSION[self::CLIPBOARD_ID] = array_unique(
592 $ilCtrl->redirect($this,
"listBadges");
600 $ilCtrl->redirect($this,
"listBadges");
609 include_once
"Services/Badge/classes/class.ilBadge.php";
610 foreach(
$_SESSION[self::CLIPBOARD_ID] as $badge_id)
612 $badge =
new ilBadge($badge_id);
613 if(in_array($badge->getTypeId(), $valid_types))
627 !is_array(
$_SESSION[self::CLIPBOARD_ID]))
629 $ilCtrl->redirect($this,
"listBadges");
634 $badge->copy($this->parent_obj_id);
637 $ilCtrl->redirect($this,
"listBadges");
646 include_once
"Services/Badge/classes/class.ilBadge.php";
647 foreach($badge_ids as $badge_id)
649 $badge =
new ilBadge($badge_id);
650 $badge->setActive($a_status);
655 $ilCtrl->redirect($this,
"listBadges");
684 include_once
"Services/Form/classes/class.ilSelectInputGUI.php";
687 $ilToolbar->addInputItem($drop,
true);
689 $ilToolbar->setFormAction($ilCtrl->getFormAction($this,
"awardBadgeUserSelection"));
690 $ilToolbar->addFormButton($lng->txt(
"badge_award_badge"),
"awardBadgeUserSelection");
694 include_once
"Services/Badge/classes/class.ilBadgeUserTableGUI.php";
696 $tpl->setContent(
$tbl->getHTML());
701 include_once
"Services/Badge/classes/class.ilBadgeUserTableGUI.php";
704 $tbl->writeFilterToSession();
710 include_once
"Services/Badge/classes/class.ilBadgeUserTableGUI.php";
721 $bid = (int)$_REQUEST[
"bid"];
725 $ilCtrl->redirect($this,
"listUsers");
729 if(!in_array($bid, $manual))
731 $ilCtrl->redirect($this,
"listUsers");
734 $back_target =
"listUsers";
735 if($_REQUEST[
"tgt"] ==
"bdgl")
737 $ilCtrl->saveParameter($this,
"tgt");
738 $back_target =
"listBadges";
741 $ilTabs->clearTargets();
742 $ilTabs->setBackTarget($lng->txt(
"back"),
743 $ilCtrl->getLinkTarget($this, $back_target));
745 $ilCtrl->setParameter($this,
"bid", $bid);
747 include_once
"./Services/Badge/classes/class.ilBadge.php";
750 include_once
"Services/Badge/classes/class.ilBadgeUserTableGUI.php";
752 $tpl->setContent(
$tbl->getHTML());
757 include_once
"Services/Badge/classes/class.ilBadgeUserTableGUI.php";
760 $tbl->writeFilterToSession();
766 include_once
"Services/Badge/classes/class.ilBadgeUserTableGUI.php";
778 $badge_id = $_REQUEST[
"bid"];
783 $ilCtrl->redirect($this,
"listUsers");
786 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
787 $new_badges =
array();
788 foreach($user_ids as $user_id)
793 $ass->setAwardedBy($ilUser->getId());
796 $new_badges[$user_id][] = $badge_id;
803 $ilCtrl->redirect($this,
"listUsers");
811 $badge_id = $_REQUEST[
"bid"];
816 $ilCtrl->redirect($this,
"listUsers");
819 $ilTabs->clearTargets();
820 $ilTabs->setBackTarget($lng->txt(
"back"),
821 $ilCtrl->getLinkTarget($this,
"listUsers"));
823 include_once
"Services/Badge/classes/class.ilBadge.php";
824 $badge =
new ilBadge($badge_id);
826 $ilCtrl->setParameter($this,
"bid", $badge->getId());
828 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
830 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
831 $confirmation_gui->setHeaderText(sprintf($lng->txt(
"badge_assignment_deletion_confirmation"), $badge->getTitle()));
832 $confirmation_gui->setCancel($lng->txt(
"cancel"),
"listUsers");
833 $confirmation_gui->setConfirm($lng->txt(
"delete"),
"deassignBadge");
835 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
838 include_once
"Services/User/classes/class.ilUserUtil.php";
839 foreach($user_ids as $user_id)
841 if(in_array($user_id, $assigned_users))
843 $confirmation_gui->addItem(
851 $tpl->setContent($confirmation_gui->getHTML());
859 $badge_id = $_REQUEST[
"bid"];
864 $ilCtrl->redirect($this,
"listUsers");
867 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
868 foreach($user_ids as $user_id)
875 $ilCtrl->redirect($this,
"listUsers");
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
Base class for ILIAS Exception handling.
getImagePath($a_full_path=true)
static exists($a_badge_id, $a_user_id)
static getAssignedUsers($a_badge_id)
resetAwardBadgeUserSelection()
getConfigGUIInstance()
Get GUI config instance.
editBadge(ilPropertyFormGUI $a_form=null)
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
applyAwardBadgeUserSelection()
__construct($a_parent_ref_id, $a_parent_obj_id=null, $a_parent_obj_type=null)
Construct.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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)
Default behaviour is:
addBadge(ilPropertyFormGUI $a_form=null)
if(!is_array($argv)) $options
static getExtendedTypeCaption(ilBadgeType $a_type)
static _lookupObjId($a_id)
This class represents a text property in a property form.
Badge type gui interface.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
TableGUI class for badge listing.
This class represents a text area property in a property form.
getBadgesFromMultiAction()
getValidBadgesFromClipboard()
awardBadgeUserSelection()
static getInstancesByBadgeId($a_badge_id)
TableGUI class for badge user listing.
Confirmation screen class.
static getInstance()
Constructor.
static getInstancesByType($a_type_unique_id)