63 public function __construct($a_parent_ref_id, $a_parent_obj_id = null, $a_parent_obj_type = null)
67 $this->lng = $DIC->language();
68 $this->ctrl = $DIC->ctrl();
69 $this->tabs = $DIC->tabs();
70 $this->access = $DIC->access();
71 $this->toolbar = $DIC->toolbar();
72 $this->tpl = $DIC[
"tpl"];
73 $this->
user = $DIC->user();
74 $lng = $DIC->language();
76 $this->parent_ref_id = $a_parent_ref_id;
77 $this->parent_obj_id = $a_parent_obj_id
80 $this->parent_obj_type = $a_parent_obj_type
88 $lng->loadLanguageModule(
"badge");
97 $next_class = $ilCtrl->getNextClass($this);
98 $cmd = $ilCtrl->getCmd(
"listBadges");
100 switch ($next_class) {
101 case "ilpropertyformgui":
103 if ((
int) $_REQUEST[
"bid"]) {
104 $badge =
new ilBadge((
int) $_REQUEST[
"bid"]);
105 $type = $badge->getTypeInstance();
111 $type_id = $_REQUEST[
"type"];
112 $ilCtrl->setParameter($this,
"type", $type_id);
114 $type = $handler->getTypeInstanceByUniqueId($type_id);
117 $ilCtrl->forwardCommand($form);
155 $lng->txt(
"obj_bdga"),
156 $ilCtrl->getLinkTarget($this,
"listBadges")
162 $ilCtrl->getLinkTarget($this,
"listUsers")
165 $ilTabs->activateSubTab($a_active);
171 return $ilAccess->checkAccess(
"write",
"", $this->parent_ref_id);
185 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
188 foreach ($valid_types as $id =>
$type) {
189 $options[$id] = ($this->parent_obj_type !=
"bdga")
191 :
$type->getCaption();
196 $drop->setOptions($options);
197 $ilToolbar->addInputItem($drop,
true);
199 $ilToolbar->setFormAction($ilCtrl->getFormAction($this,
"addBadge"));
200 $ilToolbar->addFormButton(
$lng->txt(
"create"),
"addBadge");
205 if (is_array(
$_SESSION[self::CLIPBOARD_ID])) {
207 $ilToolbar->addSeparator();
212 $tt[] = $badge->getTitle();
217 implode(
"<br />", $tt),
224 $lng->loadLanguageModule(
"content");
225 $ilToolbar->addButton(
226 $lng->txt(
"cont_paste_from_clipboard") .
227 " (" .
sizeof($tt) .
")",
228 $ilCtrl->getLinkTarget($this,
"pasteBadges"),
234 $ilToolbar->addButton(
235 $lng->txt(
"clear_clipboard"),
236 $ilCtrl->getLinkTarget($this,
"clearClipboard")
242 $tpl->setContent($tbl->getHTML());
249 $tbl->writeFilterToSession();
271 $type_id = $_REQUEST[
"type"];
274 $ilCtrl->redirect($this,
"listBadges");
277 $ilCtrl->setParameter($this,
"type", $type_id);
280 $type = $handler->getTypeInstanceByUniqueId($type_id);
282 $ilCtrl->redirect($this,
"listBadges");
289 $tpl->setContent($a_form->getHTML());
298 $form->setFormAction($ilCtrl->getFormAction($this,
"saveBadge"));
299 $form->setTitle(
$lng->txt(
"badge_badge") .
' "' . $a_type->
getCaption() .
'"');
302 $form->addItem($active);
305 $title->setRequired(
true);
306 $form->addItem($title);
310 $form->addItem($desc);
314 $form->addItem($crit);
316 if ($a_mode ==
"create") {
321 $form->addItem($img_mode);
323 $img_mode_tmpl =
new ilRadioOption(
$lng->txt(
"badge_image_from_template"),
"tmpl");
324 $img_mode->addOption($img_mode_tmpl);
327 $img_mode->addOption($img_mode_up);
331 $img_upload->setSuffixes(array(
"png",
"svg"));
332 $img_mode_up->addSubItem($img_upload);
337 if (
sizeof($valid_templates)) {
339 $options[
""] =
$lng->txt(
"please_select");
340 foreach ($valid_templates as $tmpl) {
341 $options[$tmpl->getId()] = $tmpl->getTitle();
345 $tmpl->setRequired(
true);
346 $tmpl->setOptions($options);
347 $img_mode_tmpl->addSubItem($tmpl);
350 $img_mode_tmpl->setDisabled(
true);
351 $img_mode->setValue(
"up");
356 $img_upload->setALlowDeletion(
false);
357 $img_upload->setUseCache(
false);
358 $form->addItem($img_upload);
367 $custom->initConfigForm($form, $this->parent_ref_id);
372 if ($a_mode ==
"create") {
373 $form->addCommandButton(
"saveBadge",
$lng->txt(
"save"));
375 $form->addCommandButton(
"updateBadge",
$lng->txt(
"save"));
377 $form->addCommandButton(
"listBadges",
$lng->txt(
"cancel"));
387 $type_id = $_REQUEST[
"type"];
390 $ilCtrl->redirect($this,
"listBadges");
393 $ilCtrl->setParameter($this,
"type", $type_id);
396 $type = $handler->getTypeInstanceByUniqueId($type_id);
398 $ilCtrl->redirect($this,
"listBadges");
402 $custom =
$type->getConfigGUIInstance();
404 if ($form->checkInput() &&
405 (!$custom || $custom->validateForm($form))) {
407 $badge->setParentId($this->parent_obj_id);
408 $badge->setTypeId($type_id);
409 $badge->setActive($form->getInput(
"act"));
410 $badge->setTitle($form->getInput(
"title"));
411 $badge->setDescription($form->getInput(
"desc"));
412 $badge->setCriteria($form->getInput(
"crit"));
413 $badge->setValid($form->getInput(
"valid"));
417 $badge->setConfiguration($custom->getConfigFromForm($form));
422 if ($form->getInput(
"img_mode") ==
"up") {
423 $badge->uploadImage($_FILES[
"img"]);
426 $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
429 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
430 $ilCtrl->redirect($this,
"listBadges");
433 $form->setValuesByPost();
443 $badge_id = $_REQUEST[
"bid"];
446 $ilCtrl->redirect($this,
"listBadges");
449 $ilCtrl->setParameter($this,
"bid", $badge_id);
451 $badge =
new ilBadge($badge_id);
459 $type = $badge->getTypeInstance();
464 $tpl->setContent($a_form->getHTML());
489 $badge_id = $_REQUEST[
"bid"];
492 $ilCtrl->redirect($this,
"listBadges");
495 $ilCtrl->setParameter($this,
"bid", $badge_id);
497 $badge =
new ilBadge($badge_id);
498 $type = $badge->getTypeInstance();
499 $custom =
$type->getConfigGUIInstance();
505 if ($form->checkInput() &&
506 (!$custom || $custom->validateForm($form))) {
507 $badge->setActive($form->getInput(
"act"));
508 $badge->setTitle($form->getInput(
"title"));
509 $badge->setDescription($form->getInput(
"desc"));
510 $badge->setCriteria($form->getInput(
"crit"));
511 $badge->setValid($form->getInput(
"valid"));
514 $badge->setConfiguration($custom->getConfigFromForm($form));
519 $badge->uploadImage($_FILES[
"img"]);
521 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
522 $ilCtrl->redirect($this,
"listBadges");
526 $form->setValuesByPost();
539 $ilTabs->clearTargets();
540 $ilTabs->setBackTarget(
542 $ilCtrl->getLinkTarget($this,
"listBadges")
546 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
547 $confirmation_gui->setHeaderText(
$lng->txt(
"badge_deletion_confirmation"));
548 $confirmation_gui->setCancel(
$lng->txt(
"cancel"),
"listBadges");
549 $confirmation_gui->setConfirm(
$lng->txt(
"delete"),
"deleteBadges");
551 foreach ($badge_ids as $badge_id) {
552 $badge =
new ilBadge($badge_id);
553 $confirmation_gui->addItem(
"id[]", $badge_id, $badge->getTitle() .
557 $tpl->setContent($confirmation_gui->getHTML());
567 foreach ($badge_ids as $badge_id) {
568 $badge =
new ilBadge($badge_id);
572 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
573 $ilCtrl->redirect($this,
"listBadges");
585 $badge_ids = $_REQUEST[
"id"];
588 $ilCtrl->redirect($this,
"listBadges");
600 $_SESSION[self::CLIPBOARD_ID] = array_unique(
601 array_merge((array)
$_SESSION[self::CLIPBOARD_ID], $badge_ids)
604 $ilCtrl->redirect($this,
"listBadges");
612 $ilCtrl->redirect($this,
"listBadges");
621 foreach (
$_SESSION[self::CLIPBOARD_ID] as $badge_id) {
622 $badge =
new ilBadge($badge_id);
623 if (in_array($badge->getTypeId(), $valid_types)) {
636 !is_array(
$_SESSION[self::CLIPBOARD_ID])) {
637 $ilCtrl->redirect($this,
"listBadges");
641 $badge->copy($this->parent_obj_id);
644 $ilCtrl->redirect($this,
"listBadges");
654 foreach ($badge_ids as $badge_id) {
655 $badge =
new ilBadge($badge_id);
656 $badge->setActive($a_status);
660 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
661 $ilCtrl->redirect($this,
"listBadges");
690 if (
sizeof($manual)) {
692 $drop->setOptions($manual);
693 $ilToolbar->addInputItem($drop,
true);
695 $ilToolbar->setFormAction($ilCtrl->getFormAction($this,
"awardBadgeUserSelection"));
696 $ilToolbar->addFormButton(
$lng->txt(
"badge_award_badge"),
"awardBadgeUserSelection");
701 $tpl->setContent($tbl->getHTML());
708 $tbl->writeFilterToSession();
727 $bid = (int) $_REQUEST[
"bid"];
730 $ilCtrl->redirect($this,
"listUsers");
734 if (!in_array($bid, $manual)) {
735 $ilCtrl->redirect($this,
"listUsers");
738 $back_target =
"listUsers";
739 if ($_REQUEST[
"tgt"] ==
"bdgl") {
740 $ilCtrl->saveParameter($this,
"tgt");
741 $back_target =
"listBadges";
744 $ilTabs->clearTargets();
745 $ilTabs->setBackTarget(
747 $ilCtrl->getLinkTarget($this, $back_target)
750 $ilCtrl->setParameter($this,
"bid", $bid);
754 $tbl =
new ilBadgeUserTableGUI($this,
"awardBadgeUserSelection", $this->parent_ref_id, $badge);
755 $tpl->setContent($tbl->getHTML());
762 $tbl->writeFilterToSession();
781 $badge_id = $_REQUEST[
"bid"];
785 $ilCtrl->redirect($this,
"listUsers");
788 $new_badges = array();
789 foreach ($user_ids as $user_id) {
792 $ass->setAwardedBy(
$ilUser->getId());
795 $new_badges[$user_id][] = $badge_id;
801 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
802 $ilCtrl->redirect($this,
"listUsers");
813 $badge_id = $_REQUEST[
"bid"];
817 $ilCtrl->redirect($this,
"listUsers");
820 $ilTabs->clearTargets();
821 $ilTabs->setBackTarget(
823 $ilCtrl->getLinkTarget($this,
"listUsers")
826 $badge =
new ilBadge($badge_id);
828 $ilCtrl->setParameter($this,
"bid", $badge->getId());
831 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
832 $confirmation_gui->setHeaderText(sprintf(
$lng->txt(
"badge_assignment_deletion_confirmation"), $badge->getTitle()));
833 $confirmation_gui->setCancel(
$lng->txt(
"cancel"),
"listUsers");
834 $confirmation_gui->setConfirm(
$lng->txt(
"delete"),
"deassignBadge");
838 foreach ($user_ids as $user_id) {
839 if (in_array($user_id, $assigned_users)) {
840 $confirmation_gui->addItem(
848 $tpl->setContent($confirmation_gui->getHTML());
857 $badge_id = $_REQUEST[
"bid"];
861 $ilCtrl->redirect($this,
"listUsers");
864 foreach ($user_ids as $user_id) {
869 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
870 $ilCtrl->redirect($this,
"listUsers");
This class represents an option in a radio group.
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
Class ilBadgeManagementGUI.
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.
addBadge(ilPropertyFormGUI $a_form=null)
foreach($_POST as $key=> $value) $res
static getExtendedTypeCaption(ilBadgeType $a_type)
static _lookupObjId($a_id)
Badge type gui interface.
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 _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)