ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSurveyParticipantsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
15{
16 public function __construct(ilObjSurveyGUI $a_parent_gui)
17 {
18 global $ilCtrl, $lng, $tpl;
19
20 $this->parent_gui = $a_parent_gui;
21 $this->object = $this->parent_gui->object;
22 $this->ref_id = $this->object->getRefId();
23
24 $this->ctrl = $ilCtrl;
25 $this->lng = $lng;
26 $this->tpl = $tpl;
27 }
28
29 public function executeCommand()
30 {
31 global $ilCtrl, $ilTabs;
32
33 $cmd = $ilCtrl->getCmd("maintenance");
34 $next_class = $this->ctrl->getNextClass($this);
35
36 switch($next_class)
37 {
38 case 'ilrepositorysearchgui':
39 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
40 $rep_search =& new ilRepositorySearchGUI();
41
42 if(!$_REQUEST["appr360"] && !$_REQUEST["rate360"])
43 {
44 $ilTabs->clearTargets();
45 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
46 $this->ctrl->getLinkTarget($this, "invite"));
47
48 $rep_search->setCallback($this,
49 'inviteUserGroupObject',
50 array(
51 )
52 );
53
54 // Set tabs
55 $this->ctrl->setReturn($this, 'invite');
56 $this->ctrl->forwardCommand($rep_search);
57 $ilTabs->setTabActive('invitation');
58 }
59 else if($_REQUEST["rate360"])
60 {
61 $ilTabs->clearTargets();
62 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
63 $this->ctrl->getLinkTarget($this, "listAppraisees"));
64
65 $this->ctrl->setParameter($this, "rate360", 1);
66 $this->ctrl->saveParameter($this, "appr_id");
67
68 $rep_search->setCallback($this,
69 'addRater',
70 array(
71 )
72 );
73
74 // Set tabs
75 $this->ctrl->setReturn($this, 'editRaters');
76 $this->ctrl->forwardCommand($rep_search);
77 }
78 else
79 {
80 $ilTabs->activateTab("survey_360_appraisees");
81 $this->ctrl->setParameter($this, "appr360", 1);
82
83 $rep_search->setCallback($this,
84 'addAppraisee',
85 array(
86 )
87 );
88
89 // Set tabs
90 $this->ctrl->setReturn($this, 'listAppraisees');
91 $this->ctrl->forwardCommand($rep_search);
92 }
93 break;
94
95 default:
96 $cmd .= "Object";
97 $this->$cmd();
98 break;
99 }
100 }
101
105 public function maintenanceObject()
106 {
107 global $ilToolbar;
108
109 if($this->object->get360Mode())
110 {
111 return $this->listAppraiseesObject();
112 }
113
114 $this->parent_gui->handleWriteAccess();
115 $this->setCodesSubtabs();
116
117 $ilToolbar->addButton($this->lng->txt('svy_delete_all_user_data'),
118 $this->ctrl->getLinkTarget($this, 'deleteAllUserData'));
119
120 /* don't want
121 if (DEVMODE && $_GET["fill"] > 0)
122 {
123 for ($i = 0; $i < $_GET["fill"]; $i++) $this->object->fillSurveyForUser();
124 }
125 */
126
127 include_once "./Modules/Survey/classes/tables/class.ilSurveyMaintenanceTableGUI.php";
128 $table_gui = new ilSurveyMaintenanceTableGUI($this, 'maintenance');
129 $total =& $this->object->getSurveyParticipants();
130 $data = array();
131 foreach ($total as $user_data)
132 {
133 $finished = false;
134 if((bool)$user_data["finished"])
135 {
136 $finished = $user_data["finished_tstamp"];
137 }
138 $wt = $this->object->getWorkingtimeForParticipant($user_data["active_id"]);
139 $last_access = $this->object->_getLastAccess($user_data["active_id"]);
140 array_push($data, array(
141 'id' => $user_data["active_id"],
142 'name' => $user_data["sortname"],
143 'login' => $user_data["login"],
144 'last_access' => $last_access,
145 'workingtime' => $wt,
146 'finished' => $finished
147 ));
148 }
149 $table_gui->setData($data);
150 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
151 }
152
159 {
160 global $ilTabs;
161
162 // not used in 360° mode
163
164 // maintenance
165 $ilTabs->addSubTabTarget("results",
166 $this->ctrl->getLinkTarget($this,'maintenance'),
167 array("maintenance", "deleteAllUserData"),
168 "");
169
170 if(!$this->object->isAccessibleWithoutCode())
171 {
172 $ilTabs->addSubTabTarget("codes",
173 $this->ctrl->getLinkTarget($this,'codes'),
174 array("codes", "editCodes", "createSurveyCodes", "setCodeLanguage", "deleteCodes", "exportCodes",
175 "importExternalMailRecipientsFromFileForm", "importExternalMailRecipientsFromTextForm"),
176 ""
177 );
178 }
179
180 $hidden_tabs = array();
181 $template = $this->object->getTemplate();
182 if($template)
183 {
184 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
185 $template = new ilSettingsTemplate($template);
186 $hidden_tabs = $template->getHiddenTabs();
187 }
188
189 // #12277 - invite
190 if(!in_array("invitation", $hidden_tabs))
191 {
192 $ilTabs->addSubTabTarget("invitation",
193 $this->ctrl->getLinkTarget($this, 'invite'),
194 array("invite", "saveInvitationStatus",
195 "inviteUserGroup", "disinviteUserGroup"),
196 "");
197 }
198
199 $data = $this->object->getExternalCodeRecipients();
200 if (count($data))
201 {
202 $ilTabs->addSubTabTarget
203 (
204 "mail_survey_codes",
205 $this->ctrl->getLinkTarget($this, "mailCodes"),
206 array("mailCodes", "sendCodesMail", "insertSavedMessage", "deleteSavedMessage"),
207 ""
208 );
209 }
210 }
211
215 public function disinviteUserGroupObject()
216 {
217 // disinvite users
218 if (is_array($_POST["user_select"]))
219 {
220 foreach ($_POST["user_select"] as $user_id)
221 {
222 $this->object->disinviteUser($user_id);
223 }
224 }
225 ilUtil::sendSuccess($this->lng->txt('msg_users_disinvited'), true);
226 $this->ctrl->redirect($this, "invite");
227 }
228
232 public function inviteUserGroupObject($a_user_ids = array())
233 {
234 $invited = 0;
235 // add users to invitation
236 if (is_array($a_user_ids))
237 {
238 foreach ($a_user_ids as $user_id)
239 {
240 $this->object->inviteUser($user_id);
241 $invited++;
242 }
243 }
244 if ($invited == 0)
245 {
246 ilUtil::sendFailure($this->lng->txt('no_user_invited'), TRUE);
247 return false;
248 }
249 else
250 {
251 ilUtil::sendSuccess(sprintf($this->lng->txt('users_invited'), $invited), TRUE);
252 return false;
253 }
254 $this->ctrl->redirect($this, "invite");
255 }
256
261 {
262 $mode = $_POST['invitation'];
263 switch ($mode)
264 {
265 case 0:
266 $this->object->setInvitation(ilObjSurvey::INVITATION_OFF);
267 break;
268 case 1:
269 $this->object->setInvitationAndMode(ilObjSurvey::INVITATION_ON, ilObjSurvey::MODE_UNLIMITED);
270 break;
271 case 2:
272 $this->object->setInvitationAndMode(ilObjSurvey::INVITATION_ON, ilObjSurvey::MODE_PREDEFINED_USERS);
273 break;
274 }
275 $this->object->saveToDb();
276 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
277 $this->ctrl->redirect($this, "invite");
278 }
279
283 public function inviteObject()
284 {
285 global $ilAccess;
286 global $rbacsystem;
287 global $ilToolbar;
288 global $lng;
289
290 $this->parent_gui->handleWriteAccess();
291 $this->setCodesSubtabs();
292
293 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
294 $form = new ilPropertyFormGUI();
295 $form->setFormAction($this->ctrl->getFormAction($this));
296 $form->setTableWidth("500");
297 $form->setId("invite");
298
299 // invitation
301 $header->setTitle($this->lng->txt("invitation"));
302 $form->addItem($header);
303
304 // invitation mode
305 $invitation = new ilRadioGroupInputGUI($this->lng->txt('invitation_mode'), "invitation");
306 $invitation->setInfo($this->lng->txt('invitation_mode_desc'));
307 $invitation->addOption(new ilRadioOption($this->lng->txt("invitation_off"), 0, ''));
308 $surveySetting = new ilSetting("survey");
309 if ($surveySetting->get("unlimited_invitation"))
310 {
311 $invitation->addOption(new ilRadioOption($this->lng->txt("unlimited_users"), 1, ''));
312 }
313 $invitation->addOption(new ilRadioOption($this->lng->txt("predefined_users"), 2, ''));
314 $inv = 0;
315 if ($this->object->getInvitation())
316 {
317 $inv = $this->object->getInvitationMode() + 1;
318 }
319 $invitation->setValue($inv);
320 $form->addItem($invitation);
321
322 $form->addCommandButton("saveInvitationStatus", $this->lng->txt("save"));
323
324 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_invite.html", "Modules/Survey");
325 $this->tpl->setVariable("INVITATION_TABLE", $form->getHTML());
326
327 if ($this->object->getInvitation() && $this->object->getInvitationMode() == 1)
328 {
329 // search button
330 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
332 $this,
333 $tb,
334 array(
335 'auto_complete_name' => $lng->txt('user'),
336 'submit_name' => $lng->txt('svy_invite_action')
337 )
338 );
339
340 $ilToolbar->addSpacer();
341
342 $ilToolbar->addButton($this->lng->txt("svy_search_users"),
343 $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI',''));
344
345 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
346
347 $invited_users = $this->object->getUserData($this->object->getInvitedUsers());
348 include_once "./Modules/Survey/classes/tables/class.ilSurveyInvitedUsersTableGUI.php";
349 $table_gui = new ilSurveyInvitedUsersTableGUI($this, 'invite');
350 $table_gui->setData($invited_users);
351 $this->tpl->setVariable('TBL_INVITED_USERS', $table_gui->getHTML());
352 }
353 }
354
358 public function deleteAllUserDataObject()
359 {
360 include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
361 $cgui = new ilConfirmationGUI();
362 $cgui->setHeaderText($this->lng->txt("confirm_delete_all_user_data"));
363 $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteAllUserData"));
364 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteAllUserData");
365 $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteAllUserData");
366 $this->tpl->setContent($cgui->getHTML());
367 }
368
373 {
374 $this->object->deleteAllUserData();
375
376 // #11558 - re-open closed appraisees
377 if($this->object->get360Mode())
378 {
379 $this->object->openAllAppraisees();
380 }
381
382 ilUtil::sendSuccess($this->lng->txt("svy_all_user_data_deleted"), true);
383 $this->ctrl->redirect($this, "maintenance");
384 }
385
390 {
391 $this->ctrl->redirect($this, "maintenance");
392 }
393
398 {
399 $this->object->removeSelectedSurveyResults($_POST["chbUser"]);
400 ilUtil::sendSuccess($this->lng->txt("svy_selected_user_data_deleted"), true);
401 $this->ctrl->redirect($this, "maintenance");
402 }
403
408 {
409 ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
410 $this->ctrl->redirect($this, "maintenance");
411 }
412
417 {
418 $this->parent_gui->handleWriteAccess();
419
420 if (count($_POST["chbUser"]) == 0)
421 {
422 ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
423 $this->ctrl->redirect($this, "maintenance");
424 }
425
426 ilUtil::sendQuestion($this->lng->txt("confirm_delete_single_user_data"));
427 include_once "./Modules/Survey/classes/tables/class.ilSurveyMaintenanceTableGUI.php";
428 $table_gui = new ilSurveyMaintenanceTableGUI($this, 'maintenance', true);
429 $total =& $this->object->getSurveyParticipants();
430 $data = array();
431 foreach ($total as $user_data)
432 {
433 if (in_array($user_data['active_id'], $_POST['chbUser']))
434 {
435 $last_access = $this->object->_getLastAccess($user_data["active_id"]);
436 array_push($data, array(
437 'id' => $user_data["active_id"],
438 'name' => $user_data["sortname"],
439 'login' => $user_data["login"],
440 'last_access' => $last_access
441 ));
442 }
443 }
444 $table_gui->setData($data);
445 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
446 }
447
451 public function setCodeLanguageObject()
452 {
453 if (strcmp($_POST["lang"], "-1") != 0)
454 {
455 global $ilUser;
456 $ilUser->writePref("survey_code_language", $_POST["lang"]);
457 }
458 ilUtil::sendSuccess($this->lng->txt('language_changed'), true);
459 $this->ctrl->redirect($this, 'codes');
460 }
461
465 public function codesObject()
466 {
467 global $ilUser, $ilToolbar;
468
469 $this->parent_gui->handleWriteAccess();
470 $this->setCodesSubtabs();
471
472 if ($this->object->isAccessibleWithoutCode())
473 {
474 return ilUtil::sendInfo($this->lng->txt("survey_codes_no_anonymization"));
475 }
476
477 $default_lang = $ilUser->getPref("survey_code_language");
478
479 // creation buttons
480 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
481
482 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
483 $si = new ilTextInputGUI($this->lng->txt("new_survey_codes"), "nrOfCodes");
484 $si->setValue(1);
485 $si->setSize(3);
486 $ilToolbar->addInputItem($si, true);
487
488 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
489
490 $button = ilSubmitButton::getInstance();
491 $button->setCaption("create");
492 $button->setCommand("createSurveyCodes");
493 $ilToolbar->addButtonInstance($button);
494
495 $ilToolbar->addSeparator();
496
497 $button = ilSubmitButton::getInstance();
498 $button->setCaption("import_from_file");
499 $button->setCommand("importExternalMailRecipientsFromFileForm");
500 $ilToolbar->addButtonInstance($button);
501
502 $button = ilSubmitButton::getInstance();
503 $button->setCaption("import_from_text");
504 $button->setCommand("importExternalMailRecipientsFromTextForm");
505 $ilToolbar->addButtonInstance($button);
506
507 $ilToolbar->addSeparator();
508
509 $button = ilSubmitButton::getInstance();
510 $button->setCaption("svy_import_codes");
511 $button->setCommand("importAccessCodes");
512 $ilToolbar->addButtonInstance($button);
513
514 $ilToolbar->addSeparator();
515
516 $languages = $this->lng->getInstalledLanguages();
517 $options = array();
518 $this->lng->loadLanguageModule("meta");
519 foreach ($languages as $lang)
520 {
521 $options[$lang] = $this->lng->txt("meta_l_".$lang);
522 }
523 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
524 $si = new ilSelectInputGUI($this->lng->txt("survey_codes_lang"), "lang");
525 $si->setOptions($options);
526 $si->setValue($default_lang);
527 $ilToolbar->addInputItem($si, true);
528
529 $button = ilSubmitButton::getInstance();
530 $button->setCaption("set");
531 $button->setCommand("setCodeLanguage");
532 $ilToolbar->addButtonInstance($button);
533
534 include_once "./Modules/Survey/classes/tables/class.ilSurveyCodesTableGUI.php";
535 $table_gui = new ilSurveyCodesTableGUI($this, 'codes');
536 $survey_codes = $this->object->getSurveyCodesTableData(null, $default_lang);
537 $table_gui->setData($survey_codes);
538 $this->tpl->setContent($table_gui->getHTML());
539 }
540
541 public function editCodesObject()
542 {
543 if(isset($_GET["new_ids"]))
544 {
545 $ids = explode(";", $_GET["new_ids"]);
546 }
547 else
548 {
549 $ids = (array)$_POST["chb_code"];
550 }
551 if(!$ids)
552 {
553 ilUtil::sendFailure($this->lng->txt('no_checkbox'), true);
554 $this->ctrl->redirect($this, 'codes');
555 }
556
557 $this->parent_gui->handleWriteAccess();
558 $this->setCodesSubtabs();
559
560 include_once "./Modules/Survey/classes/tables/class.ilSurveyCodesEditTableGUI.php";
561 $table_gui = new ilSurveyCodesEditTableGUI($this, 'editCodes');
562 $table_gui->setData($this->object->getSurveyCodesTableData($ids));
563 $this->tpl->setContent($table_gui->getHTML());
564 }
565
566 public function updateCodesObject()
567 {
568 if(!is_array($_POST["chb_code"]))
569 {
570 $this->ctrl->redirect($this, 'codes');
571 }
572
573 foreach($_POST["chb_code"] as $id)
574 {
575 $this->object->updateCode($id,
576 $_POST["chb_mail"][$id],
577 $_POST["chb_lname"][$id],
578 $_POST["chb_fname"][$id],
579 $_POST["chb_sent"][$id]
580 );
581 }
582
583 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
584 $this->ctrl->redirect($this, 'codes');
585 }
586
587 public function deleteCodesConfirmObject()
588 {
589 if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
590 {
591 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
592 $cgui = new ilConfirmationGUI();
593 $cgui->setHeaderText($this->lng->txt("survey_code_delete_sure"));
594
595 $cgui->setFormAction($this->ctrl->getFormAction($this));
596 $cgui->setCancel($this->lng->txt("cancel"), "codes");
597 $cgui->setConfirm($this->lng->txt("confirm"), "deleteCodes");
598
599 $data = $this->object->getSurveyCodesTableData($_POST["chb_code"]);
600
601 foreach ($data as $item)
602 {
603 if($item["used"])
604 {
605 continue;
606 }
607
608 $title = array($item["code"]);
609 $item["email"] ? $title[] = $item["email"] : null;
610 $item["last_name"] ? $title[] = $item["last_name"] : null;
611 $item["first_name"] ? $title[] = $item["first_name"] : null;
612 $title = implode(", ", $title);
613
614 $cgui->addItem("chb_code[]", $item["code"], $title);
615 }
616
617 $this->tpl->setContent($cgui->getHTML());
618 }
619 else
620 {
621 ilUtil::sendFailure($this->lng->txt('no_checkbox'), true);
622 $this->ctrl->redirect($this, 'codes');
623 }
624 }
625
629 public function deleteCodesObject()
630 {
631 if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
632 {
633 foreach ($_POST["chb_code"] as $survey_code)
634 {
635 $this->object->deleteSurveyCode($survey_code);
636 }
637 ilUtil::sendSuccess($this->lng->txt('codes_deleted'), true);
638 }
639 else
640 {
641 ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
642 }
643 $this->ctrl->redirect($this, 'codes');
644 }
645
649 public function exportCodesObject()
650 {
651 if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
652 {
653 $export = $this->object->getSurveyCodesForExport(null, $_POST["chb_code"]);
654 ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".csv"));
655 }
656 else
657 {
658 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
659 $this->ctrl->redirect($this, 'codes');
660 }
661 }
662
666 public function exportAllCodesObject()
667 {
668 $export = $this->object->getSurveyCodesForExport();
669 ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".csv"));
670 }
671
675 protected function importAccessCodesObject()
676 {
677 $this->parent_gui->handleWriteAccess();
678 $this->setCodesSubtabs();
679
680 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
681 $form_import_file = new ilPropertyFormGUI();
682 $form_import_file->setFormAction($this->ctrl->getFormAction($this));
683 $form_import_file->setTableWidth("100%");
684 $form_import_file->setId("codes_import_file");
685
686 $headerfile = new ilFormSectionHeaderGUI();
687 $headerfile->setTitle($this->lng->txt("svy_import_codes"));
688 $form_import_file->addItem($headerfile);
689
690 $export_file = new ilFileInputGUI($this->lng->txt("codes"), "codes");
691 $export_file->setInfo(sprintf($this->lng->txt('svy_import_codes_info'),
692 $this->lng->txt("export_all_survey_codes")));
693 $export_file->setSuffixes(array("csv"));
694 $export_file->setRequired(true);
695 $form_import_file->addItem($export_file);
696
697 $form_import_file->addCommandButton("importAccessCodesAction", $this->lng->txt("import"));
698 $form_import_file->addCommandButton("codes", $this->lng->txt("cancel"));
699
700 $this->tpl->setContent($form_import_file->getHTML());
701 }
702
706 protected function importAccessCodesActionObject()
707 {
708 if(trim($_FILES['codes']['tmp_name']))
709 {
710 $existing = array();
711 foreach($this->object->getSurveyCodesTableData() as $item)
712 {
713 $existing[$item["code"]] = $item["id"];
714 }
715
716 include_once "./Services/Utilities/classes/class.ilCSVReader.php";
717 $reader = new ilCSVReader();
718 $reader->open($_FILES['codes']['tmp_name']);
719 foreach($reader->getDataArrayFromCSVFile() as $row)
720 {
721 if(sizeof($row) == 8)
722 {
723 // used/sent/url are not relevant when importing
724 list($code, $email, $last_name, $first_name, $created, $used, $sent, $url) = $row;
725
726 // unique code?
727 if(!array_key_exists($code, $existing))
728 {
729 // could be date or datetime
730 if(strlen($created) == 10)
731 {
732 $created = new ilDate($created, IL_CAL_DATE);
733 }
734 else
735 {
736 $created = new ilDateTime($created, IL_CAL_DATETIME);
737 }
738 $created = $created->get(IL_CAL_UNIX);
739
740 $user_data = array(
741 "email" => $email
742 ,"lastname" => $last_name
743 ,"firstname" => $first_name
744 );
745 $this->object->importSurveyCode($code, $created, $user_data);
746 }
747 }
748 }
749
750 ilUtil::sendSuccess($this->lng->txt('codes_created'), true);
751 }
752
753 $this->ctrl->redirect($this, 'codes');
754 }
755
759 public function createSurveyCodesObject()
760 {
761 if (is_numeric($_POST["nrOfCodes"]))
762 {
763 $ids = $this->object->createSurveyCodes($_POST["nrOfCodes"]);
764 ilUtil::sendSuccess($this->lng->txt('codes_created'), true);
765 $this->ctrl->setParameter($this, "new_ids", implode(";", $ids));
766 $this->ctrl->redirect($this, 'editCodes');
767 }
768 else
769 {
770 ilUtil::sendFailure($this->lng->txt("enter_valid_number_of_codes"), true);
771 $this->ctrl->redirect($this, 'codes');
772 }
773 }
774
775 public function insertSavedMessageObject()
776 {
777 $this->parent_gui->handleWriteAccess();
778 $this->setCodesSubtabs();
779
780 include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
781 $form_gui = new FormMailCodesGUI($this);
782 $form_gui->setValuesByPost();
783 try
784 {
785 if ($form_gui->getSavedMessages()->getValue() > 0)
786 {
787 global $ilUser;
788 $settings = $this->object->getUserSettings($ilUser->getId(), 'savemessage');
789 $form_gui->getMailMessage()->setValue($settings[$form_gui->getSavedMessages()->getValue()]['value']);
790 ilUtil::sendSuccess($this->lng->txt('msg_message_inserted'));
791 }
792 else
793 {
794 ilUtil::sendFailure($this->lng->txt('msg_no_message_inserted'));
795 }
796 }
797 catch (Exception $e)
798 {
799 global $ilLog;
800 $ilLog->write('Error: ' + $e->getMessage());
801 }
802 $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
803 }
804
805 public function deleteSavedMessageObject()
806 {
807 $this->parent_gui->handleWriteAccess();
808 $this->setCodesSubtabs();
809
810 include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
811 $form_gui = new FormMailCodesGUI($this);
812 $form_gui->setValuesByPost();
813 try
814 {
815 if ($form_gui->getSavedMessages()->getValue() > 0)
816 {
817 $this->object->deleteUserSettings($form_gui->getSavedMessages()->getValue());
818 $form_gui = new FormMailCodesGUI($this);
819 $form_gui->setValuesByPost();
820 ilUtil::sendSuccess($this->lng->txt('msg_message_deleted'));
821 }
822 else
823 {
824 ilUtil::sendFailure($this->lng->txt('msg_no_message_deleted'));
825 }
826 }
827 catch (Exception $e)
828 {
829 global $ilLog;
830 $ilLog->write('Error: ' + $e->getMessage());
831 }
832 $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
833 }
834
835 public function mailCodesObject()
836 {
837 $this->parent_gui->handleWriteAccess();
838 $this->setCodesSubtabs();
839
840 $mailData['m_subject'] = (array_key_exists('m_subject', $_POST)) ? $_POST['m_subject'] : sprintf($this->lng->txt('default_codes_mail_subject'), $this->object->getTitle());
841 $mailData['m_message'] = (array_key_exists('m_message', $_POST)) ? $_POST['m_message'] : $this->lng->txt('default_codes_mail_message');
842 $mailData['m_notsent'] = (array_key_exists('m_notsent', $_POST)) ? $_POST['m_notsent'] : '1';
843
844 include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
845 $form_gui = new FormMailCodesGUI($this);
846 $form_gui->setValuesByArray($mailData);
847 $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
848 }
849
850 public function sendCodesMailObject()
851 {
852 global $ilUser;
853
854 $this->parent_gui->handleWriteAccess();
855 $this->setCodesSubtabs();
856
857 include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
858 $form_gui = new FormMailCodesGUI($this);
859 if ($form_gui->checkInput())
860 {
861 $url_exists = strpos($_POST['m_message'], '[url]') !== FALSE;
862 if (!$url_exists)
863 {
864 ilUtil::sendFailure($this->lng->txt('please_enter_mail_url'));
865 $form_gui->setValuesByPost();
866 }
867 else
868 {
869 if ($_POST['savemessage'] == 1)
870 {
871 global $ilUser;
872 $title = (strlen($_POST['savemessagetitle'])) ? $_POST['savemessagetitle'] : ilStr::substr($_POST['m_message'], 0, 40) . '...';
873 $this->object->saveUserSettings($ilUser->getId(), 'savemessage', $title, $_POST['m_message']);
874 }
875
876 $lang = $ilUser->getPref("survey_code_language");
877 if(!$lang)
878 {
879 $lang = $this->lng->getDefaultLanguage();
880 }
881 $this->object->sendCodes($_POST['m_notsent'], $_POST['m_subject'], nl2br($_POST['m_message']),$lang);
882 ilUtil::sendSuccess($this->lng->txt('mail_sent'), true);
883 $this->ctrl->redirect($this, 'mailCodes');
884 }
885 }
886 else
887 {
888 $form_gui->setValuesByPost();
889 }
890 $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
891 }
892
894 {
895 if (trim($_POST['externaltext']))
896 {
897 $data = preg_split("/[\n\r]/", $_POST['externaltext']);
898 $fields = preg_split("/;/", array_shift($data));
899 if (!in_array('email', $fields))
900 {
901 $_SESSION['externaltext'] = $_POST['externaltext'];
902 ilUtil::sendFailure($this->lng->txt('err_external_rcp_no_email_column'), true);
903 $this->ctrl->redirect($this, 'importExternalMailRecipientsFromTextForm');
904 }
905 $existingdata = $this->object->getExternalCodeRecipients();
906 $existingcolumns = array();
907 if (count($existingdata))
908 {
909 $first = array_shift($existingdata);
910 foreach ($first as $key => $value)
911 {
912 array_push($existingcolumns, $key);
913 }
914 }
915 $founddata = array();
916 foreach ($data as $datarow)
917 {
918 $row = preg_split("/;/", $datarow);
919 if (count($row) == count($fields))
920 {
921 $dataset = array();
922 foreach ($fields as $idx => $fieldname)
923 {
924 if (count($existingcolumns))
925 {
926 if (array_key_exists($idx, $existingcolumns))
927 {
928 $dataset[$fieldname] = $row[$idx];
929 }
930 }
931 else
932 {
933 $dataset[$fieldname] = $row[$idx];
934 }
935 }
936 if (strlen($dataset['email']))
937 {
938 array_push($founddata, $dataset);
939 }
940 }
941 }
942 $this->object->createSurveyCodesForExternalData($founddata);
943 ilUtil::sendSuccess($this->lng->txt('external_recipients_imported'), true);
944 $this->ctrl->redirect($this, 'codes');
945 }
946
947 $this->ctrl->redirect($this, 'importExternalMailRecipientsFromTextForm');
948 }
949
950 // see ilBookmarkImportExport
951 protected function _convertCharset($a_string, $a_from_charset="", $a_to_charset="UTF-8")
952 {
953 if(extension_loaded("mbstring"))
954 {
955 if(!$a_from_charset)
956 {
957 mb_detect_order("UTF-8, ISO-8859-1, Windows-1252, ASCII");
958 $a_from_charset = mb_detect_encoding($a_string);
959 }
960 if(strtoupper($a_from_charset) != $a_to_charset)
961 {
962 return @mb_convert_encoding($a_string, $a_to_charset, $a_from_charset);
963 }
964 }
965 return $a_string;
966 }
967
968 protected function removeUTF8Bom($a_text)
969 {
970 $bom = pack('H*','EFBBBF');
971 return preg_replace('/^'.$bom.'/', '', $a_text);
972 }
973
975 {
976 if (trim($_FILES['externalmails']['tmp_name']))
977 {
978 include_once "./Services/Utilities/classes/class.ilCSVReader.php";
979 $reader = new ilCSVReader();
980 $reader->open($_FILES['externalmails']['tmp_name']);
981 $data = $reader->getDataArrayFromCSVFile();
982 $fields = array_shift($data);
983 foreach($fields as $idx => $field)
984 {
985 $fields[$idx] = $this->removeUTF8Bom($field);
986 }
987 if (!in_array('email', $fields))
988 {
989 $reader->close();
990 ilUtil::sendFailure($this->lng->txt('err_external_rcp_no_email'), true);
991 $this->ctrl->redirect($this, 'codes');
992 }
993 $existingdata = $this->object->getExternalCodeRecipients();
994 $existingcolumns = array();
995 if (count($existingdata))
996 {
997 $first = array_shift($existingdata);
998 foreach ($first as $key => $value)
999 {
1000 array_push($existingcolumns, $key);
1001 }
1002 }
1003
1004 include_once "Services/Utilities/classes/class.ilStr.php";
1005
1006 $founddata = array();
1007 foreach ($data as $row)
1008 {
1009 if (count($row) == count($fields))
1010 {
1011 $dataset = array();
1012 foreach ($fields as $idx => $fieldname)
1013 {
1014 // #14811
1015 $row[$idx] = $this->_convertCharset($row[$idx]);
1016
1017 if (count($existingcolumns))
1018 {
1019 if (array_key_exists($idx, $existingcolumns))
1020 {
1021 $dataset[$fieldname] = $row[$idx];
1022 }
1023 }
1024 else
1025 {
1026 $dataset[$fieldname] = $row[$idx];
1027 }
1028 }
1029 if (strlen($dataset['email']))
1030 {
1031 array_push($founddata, $dataset);
1032 }
1033 }
1034 }
1035 $reader->close();
1036
1037 if(sizeof($founddata))
1038 {
1039 $this->object->createSurveyCodesForExternalData($founddata);
1040 ilUtil::sendSuccess($this->lng->txt('external_recipients_imported'), true);
1041 }
1042 }
1043
1044 $this->ctrl->redirect($this, 'codes');
1045 }
1046
1048 {
1049 global $ilAccess;
1050
1051 $this->parent_gui->handleWriteAccess();
1052 $this->setCodesSubtabs();
1053
1054 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1055 $form_import_file = new ilPropertyFormGUI();
1056 $form_import_file->setFormAction($this->ctrl->getFormAction($this));
1057 $form_import_file->setTableWidth("100%");
1058 $form_import_file->setId("codes_import_file");
1059
1060 $headerfile = new ilFormSectionHeaderGUI();
1061 $headerfile->setTitle($this->lng->txt("import_from_file"));
1062 $form_import_file->addItem($headerfile);
1063
1064 $externalmails = new ilFileInputGUI($this->lng->txt("externalmails"), "externalmails");
1065 $externalmails->setInfo($this->lng->txt('externalmails_info'));
1066 $externalmails->setRequired(true);
1067 $form_import_file->addItem($externalmails);
1068 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_file->addCommandButton("importExternalRecipientsFromFile", $this->lng->txt("import"));
1069 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_file->addCommandButton("codes", $this->lng->txt("cancel"));
1070
1071 $this->tpl->setContent($form_import_file->getHTML());
1072 }
1073
1075 {
1076 global $ilAccess;
1077
1078 $this->parent_gui->handleWriteAccess();
1079 $this->setCodesSubtabs();
1080
1081 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1082 $form_import_text = new ilPropertyFormGUI();
1083 $form_import_text->setFormAction($this->ctrl->getFormAction($this));
1084 $form_import_text->setTableWidth("100%");
1085 $form_import_text->setId("codes_import_text");
1086
1087 $headertext = new ilFormSectionHeaderGUI();
1088 $headertext->setTitle($this->lng->txt("import_from_text"));
1089 $form_import_text->addItem($headertext);
1090
1091 $inp = new ilTextAreaInputGUI($this->lng->txt('externaltext'), 'externaltext');
1092 if (array_key_exists('externaltext', $_SESSION) && strlen($_SESSION['externaltext']))
1093 {
1094 $inp->setValue($_SESSION['externaltext']);
1095 }
1096 else
1097 {
1098 // $this->lng->txt('mail_import_example1') #14897
1099 $inp->setValue("email;firstname;lastname\n" . $this->lng->txt('mail_import_example2') . "\n" . $this->lng->txt('mail_import_example3') . "\n");
1100 }
1101 $inp->setRequired(true);
1102 $inp->setCols(80);
1103 $inp->setRows(10);
1104 $inp->setInfo($this->lng->txt('externaltext_info'));
1105 $form_import_text->addItem($inp);
1106 unset($_SESSION['externaltext']);
1107
1108 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_text->addCommandButton("importExternalRecipientsFromText", $this->lng->txt("import"));
1109 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_text->addCommandButton("codes", $this->lng->txt("cancel"));
1110
1111 $this->tpl->setContent($form_import_text->getHTML());
1112 }
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123 //
1124 // 360°
1125 //
1126
1127
1128
1129
1130 public function listAppraiseesObject()
1131 {
1132 global $ilToolbar, $lng, $ilCtrl;
1133
1134 $this->parent_gui->handleWriteAccess();
1135
1136 $this->ctrl->setParameter($this, "appr360", 1);
1137
1138 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1140 $this,
1141 $ilToolbar,
1142 array(
1143 'auto_complete_name' => $this->lng->txt('user'),
1144 'submit_name' => $this->lng->txt('add'),
1145 'add_search' => true,
1146 'add_from_container' => $this->ref_id
1147 )
1148 );
1149
1150 // competence calculations
1151 include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
1152 $skmg_set = new ilSkillManagementSettings();
1153 if ($this->object->get360SkillService() && $skmg_set->isActivated())
1154 {
1155 $ilToolbar->addSeparator();
1156 $ilToolbar->addButton($lng->txt("survey_calc_skills"),
1157 $ilCtrl->getLinkTargetByClass("ilsurveyskilldeterminationgui"), "");
1158 }
1159
1160 $ilToolbar->addSeparator();
1161 $ilToolbar->addButton($this->lng->txt('svy_delete_all_user_data'),
1162 $this->ctrl->getLinkTarget($this, 'deleteAllUserData'));
1163
1164 $this->ctrl->setParameter($this, "appr360", "");
1165
1166 include_once "Modules/Survey/classes/tables/class.ilSurveyAppraiseesTableGUI.php";
1167 $tbl = new ilSurveyAppraiseesTableGUI($this, "listAppraisees");
1168 $tbl->setData($this->object->getAppraiseesData());
1169 $this->tpl->setContent($tbl->getHTML());
1170 }
1171
1172 public function addAppraisee($a_user_ids)
1173 {
1174 if(sizeof($a_user_ids))
1175 {
1176 // #13319
1177 foreach(array_unique($a_user_ids) as $user_id)
1178 {
1179 $this->object->addAppraisee($user_id);
1180 }
1181
1182 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1183 }
1184 $this->ctrl->redirect($this, "listAppraisees");
1185 }
1186
1188 {
1189 global $ilTabs;
1190
1191 if(!sizeof($_POST["appr_id"]))
1192 {
1193 ilUtil::sendFailure($this->lng->txt("select_one"), true);
1194 $this->ctrl->redirect($this, "listAppraisees");
1195 }
1196
1197 $ilTabs->clearTargets();
1198 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1199 $this->ctrl->getLinkTarget($this, "listAppraisees"));
1200
1201 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1202 $cgui = new ilConfirmationGUI();
1203 $cgui->setHeaderText($this->lng->txt("survey_360_sure_delete_appraises"));
1204
1205 $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteAppraisees"));
1206 $cgui->setCancel($this->lng->txt("cancel"), "listAppraisees");
1207 $cgui->setConfirm($this->lng->txt("confirm"), "deleteAppraisees");
1208
1209 $data = $this->object->getAppraiseesData();
1210
1211 $count = 0;
1212 include_once "Services/User/classes/class.ilUserUtil.php";
1213 foreach ($_POST["appr_id"] as $id)
1214 {
1215 if(isset($data[$id]) && !$data[$id]["closed"])
1216 {
1217 $cgui->addItem("appr_id[]", $id, ilUserUtil::getNamePresentation($id));
1218 $count++;
1219 }
1220 }
1221
1222 if(!$count)
1223 {
1224 ilUtil::sendFailure($this->lng->txt("select_one"), true);
1225 $this->ctrl->redirect($this, "listAppraisees");
1226 }
1227
1228 $this->tpl->setContent($cgui->getHTML());
1229 }
1230
1231 public function deleteAppraiseesObject()
1232 {
1233 if(sizeof($_POST["appr_id"]))
1234 {
1235 $data = $this->object->getAppraiseesData();
1236
1237 foreach ($_POST["appr_id"] as $id)
1238 {
1239 // #11285
1240 if(isset($data[$id]) && !$data[$id]["closed"])
1241 {
1242 $this->object->deleteAppraisee($id);
1243 }
1244 }
1245
1246 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1247 }
1248
1249 $this->ctrl->redirect($this, "listAppraisees");
1250 }
1251
1253 {
1254 global $ilAccess, $ilUser;
1255
1256 if ($ilAccess->checkAccess("write", "", $this->ref_id))
1257 {
1258 $appr_id = $_REQUEST["appr_id"];
1259 if(!$appr_id)
1260 {
1261 $this->ctrl->redirect($this, "listAppraisees");
1262 }
1263 return $appr_id;
1264 }
1265 else if($this->object->get360Mode() &&
1266 $this->object->get360SelfRaters() &&
1267 $this->object->isAppraisee($ilUser->getId()) &&
1268 !$this->object->isAppraiseeClosed($ilUser->getId()))
1269 {
1270 return $ilUser->getId();
1271 }
1272 $this->ctrl->redirect($this->parent_gui, "infoScreen");
1273 }
1274
1275 public function editRatersObject()
1276 {
1277 global $ilTabs, $ilToolbar, $ilAccess;
1278
1279 $appr_id = $_REQUEST["appr_id"] = $this->handleRatersAccess();
1280
1281 $has_write = $ilAccess->checkAccess("write", "", $this->ref_id);
1282 if($has_write)
1283 {
1284 $ilTabs->clearTargets();
1285 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1286 $this->ctrl->getLinkTarget($this, "listAppraisees"));
1287 }
1288
1289 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1290 $this->ctrl->setParameter($this, "rate360", 1);
1291
1292 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1294 $this,
1295 $ilToolbar,
1296 array(
1297 'auto_complete_name' => $this->lng->txt('user'),
1298 'submit_name' => $this->lng->txt('add'),
1299 'add_search' => true,
1300 'add_from_container' => $this->ref_id
1301 )
1302 );
1303
1304 $this->ctrl->setParameter($this, "rate360", "");
1305
1306 $ilToolbar->addSeparator();
1307
1308 $ilToolbar->addButton($this->lng->txt("survey_360_add_external_rater"),
1309 $this->ctrl->getLinkTarget($this, "addExternalRaterForm"));
1310
1311 // #13320
1312 require_once "Services/Link/classes/class.ilLink.php";
1313 $url = ilLink::_getStaticLink($this->object->getRefId());
1314
1315 include_once "Modules/Survey/classes/tables/class.ilSurveyAppraiseesTableGUI.php";
1316 $tbl = new ilSurveyAppraiseesTableGUI($this, "editRaters", true, !$this->object->isAppraiseeClosed($appr_id), $url); // #11285
1317 $tbl->setData($this->object->getRatersData($appr_id));
1318 $this->tpl->setContent($tbl->getHTML());
1319 }
1320
1321 public function addExternalRaterFormObject(ilPropertyFormGUI $a_form = null)
1322 {
1323 global $ilTabs, $ilAccess;
1324
1325 $appr_id = $this->handleRatersAccess();
1326 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1327
1328 $has_write = $ilAccess->checkAccess("write", "", $this->ref_id);
1329 if($has_write)
1330 {
1331 $ilTabs->clearTargets();
1332 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1333 $this->ctrl->getLinkTarget($this, "editRaters"));
1334 }
1335
1336 if(!$a_form)
1337 {
1338 $a_form = $this->initExternalRaterForm($appr_id);
1339 }
1340
1341 $this->tpl->setContent($a_form->getHTML());
1342 }
1343
1344 protected function initExternalRaterForm($appr_id)
1345 {
1346 include_once "Services/User/classes/class.ilUserUtil.php";
1347 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1348 $form = new ilPropertyFormGUI();
1349 $form->setFormAction($this->ctrl->getFormAction($this, "addExternalRater"));
1350 $form->setTitle($this->lng->txt("survey_360_add_external_rater").
1351 ": ".ilUserUtil::getNamePresentation($appr_id));
1352
1353 $email = new ilEmailInputGUI($this->lng->txt("email"), "email");
1354 $email->setRequired(true);
1355 $form->addItem($email);
1356
1357 $lname = new ilTextInputGUI($this->lng->txt("lastname"), "lname");
1358 $lname->setSize(30);
1359 $form->addItem($lname);
1360
1361 $fname = new ilTextInputGUI($this->lng->txt("firstname"), "fname");
1362 $fname->setSize(30);
1363 $form->addItem($fname);
1364
1365 $form->addCommandButton("addExternalRater", $this->lng->txt("save"));
1366 $form->addCommandButton("editRaters", $this->lng->txt("cancel"));
1367
1368 return $form;
1369 }
1370
1371 public function addExternalRaterObject()
1372 {
1373 $appr_id = $_REQUEST["appr_id"];
1374 if(!$appr_id)
1375 {
1376 $this->ctrl->redirect($this, "listAppraisees");
1377 }
1378
1379 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1380
1381 $form = $this->initExternalRaterForm($appr_id);
1382 if($form->checkInput())
1383 {
1384 $data = array(
1385 "email" => $form->getInput("email"),
1386 "lastname" => $form->getInput("lname"),
1387 "firstname" => $form->getInput("fname")
1388 );
1389 $anonymous_id = $this->object->createSurveyCodesForExternalData(array($data));
1390 $anonymous_id = array_pop($anonymous_id);
1391
1392 $this->object->addRater($appr_id, 0, $anonymous_id);
1393
1394 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1395 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1396 $this->ctrl->redirect($this, "editRaters");
1397 }
1398
1399 $form->setValuesByPost();
1400 $this->addExternalRaterFormObject($form);
1401 }
1402
1403 public function addRater($a_user_ids)
1404 {
1405 global $ilAccess, $ilUser;
1406
1407 $appr_id = $this->handleRatersAccess();
1408
1409 if(sizeof($a_user_ids))
1410 {
1411 // #13319
1412 foreach(array_unique($a_user_ids) as $user_id)
1413 {
1414 if($ilAccess->checkAccess("write", "", $this->ref_id) ||
1415 $this->object->get360SelfEvaluation() ||
1416 $user_id != $ilUser->getId())
1417 {
1418 $this->object->addRater($appr_id, $user_id);
1419 }
1420 }
1421
1422 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1423 }
1424
1425 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1426 $this->ctrl->redirect($this, "editRaters");
1427 }
1428
1430 {
1431 global $ilTabs;
1432
1433 $appr_id = $this->handleRatersAccess();
1434 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1435 if(!sizeof($_POST["rtr_id"]))
1436 {
1437 ilUtil::sendFailure($this->lng->txt("select_one"), true);
1438 $this->ctrl->redirect($this, "editRaters");
1439 }
1440
1441 $ilTabs->clearTargets();
1442 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1443 $this->ctrl->getLinkTarget($this, "editRaters"));
1444
1445 include_once "Services/User/classes/class.ilUserUtil.php";
1446 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1447 $cgui = new ilConfirmationGUI();
1448 $cgui->setHeaderText(sprintf($this->lng->txt("survey_360_sure_delete_raters"),
1450
1451 $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteRaters"));
1452 $cgui->setCancel($this->lng->txt("cancel"), "editRaters");
1453 $cgui->setConfirm($this->lng->txt("confirm"), "deleteRaters");
1454
1455 $data = $this->object->getRatersData($appr_id);
1456
1457 foreach ($_POST["rtr_id"] as $id)
1458 {
1459 if(isset($data[$id]))
1460 {
1461 $cgui->addItem("rtr_id[]", $id, $data[$id]["lastname"].", ".
1462 $data[$id]["firstname"]." (".$data[$id]["email"].")");
1463 }
1464 }
1465
1466 $this->tpl->setContent($cgui->getHTML());
1467 }
1468
1469 public function deleteRatersObject()
1470 {
1471 $appr_id = $this->handleRatersAccess();
1472 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1473
1474 if(sizeof($_POST["rtr_id"]))
1475 {
1476 $data = $this->object->getRatersData($appr_id);
1477
1478 foreach ($_POST["rtr_id"] as $id)
1479 {
1480 if(isset($data[$id]))
1481 {
1482 if(substr($id, 0, 1) == "u")
1483 {
1484 $this->object->deleteRater($appr_id, substr($id, 1));
1485 }
1486 else
1487 {
1488 $this->object->deleteRater($appr_id, 0, substr($id, 1));
1489 }
1490 }
1491 }
1492
1493 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1494 }
1495
1496 $this->ctrl->redirect($this, "editRaters");
1497 }
1498
1500 {
1501 global $ilUser;
1502
1503 if($this->object->get360SelfAppraisee() &&
1504 !$this->object->isAppraisee($ilUser->getId()))
1505 {
1506 $this->object->addAppraisee($ilUser->getId());
1507 }
1508
1509 $this->ctrl->redirect($this->parent_gui, "infoScreen");
1510 }
1511
1512 function initMailRatersForm($appr_id, array $rec_ids)
1513 {
1514 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1515 $form = new ilPropertyFormGUI();
1516 $form->setFormAction($this->ctrl->getFormAction($this, "mailRatersAction"));
1517 $form->setTitle($this->lng->txt('compose'));
1518
1519 $all_data = $this->object->getRatersData($appr_id);
1520 $rec_data = array();
1521 foreach($rec_ids as $rec_id)
1522 {
1523 if(isset($all_data[$rec_id]))
1524 {
1525 $rec_data[] = $all_data[$rec_id]["lastname"].", ".
1526 $all_data[$rec_id]["firstname"].
1527 " (".$all_data[$rec_id]["email"].")";
1528 }
1529 }
1530 sort($rec_data);
1531 $rec = new ilCustomInputGUI($this->lng->txt('recipients'));
1532 $rec->setHTML(implode("<br />", $rec_data));
1533 $form->addItem($rec);
1534
1535 $subject = new ilTextInputGUI($this->lng->txt('subject'), 'subject');
1536 $subject->setSize(50);
1537 $subject->setRequired(true);
1538 $form->addItem($subject);
1539
1540 $existingdata = $this->object->getExternalCodeRecipients();
1541 $existingcolumns = array();
1542 if (count($existingdata))
1543 {
1544 $first = array_shift($existingdata);
1545 foreach ($first as $key => $value)
1546 {
1547 if (strcmp($key, 'code') != 0 && strcmp($key, 'email') != 0 && strcmp($key, 'sent') != 0) array_push($existingcolumns, '[' . $key . ']');
1548 }
1549 }
1550
1551 $mailmessage_u = new ilTextAreaInputGUI($this->lng->txt('survey_360_rater_message_content_registered'), 'message_u');
1552 $mailmessage_u->setRequired(true);
1553 $mailmessage_u->setCols(80);
1554 $mailmessage_u->setRows(10);
1555 $form->addItem($mailmessage_u);
1556
1557 $mailmessage_a = new ilTextAreaInputGUI($this->lng->txt('survey_360_rater_message_content_anonymous'), 'message_a');
1558 $mailmessage_a->setRequired(true);
1559 $mailmessage_a->setCols(80);
1560 $mailmessage_a->setRows(10);
1561 $mailmessage_a->setInfo(sprintf($this->lng->txt('message_content_info'), join($existingcolumns, ', ')));
1562 $form->addItem($mailmessage_a);
1563
1564 $recf = new ilHiddenInputGUI("rtr_id");
1565 $recf->setValue(implode(";", $rec_ids));
1566 $form->addItem($recf);
1567
1568 $form->addCommandButton("mailRatersAction", $this->lng->txt("send"));
1569 $form->addCommandButton("editRaters", $this->lng->txt("cancel"));
1570
1571 $subject->setValue(sprintf($this->lng->txt('survey_360_rater_subject_default'), $this->object->getTitle()));
1572 $mailmessage_u->setValue($this->lng->txt('survey_360_rater_message_content_registered_default'));
1573 $mailmessage_a->setValue($this->lng->txt('survey_360_rater_message_content_anonymous_default'));
1574
1575 return $form;
1576 }
1577
1578 function mailRatersObject(ilPropertyFormGUI $a_form = null)
1579 {
1580 global $ilTabs;
1581
1582 if(!$a_form)
1583 {
1584 $appr_id = $this->handleRatersAccess();
1585 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1586
1587 if(!sizeof($_POST["rtr_id"]))
1588 {
1589 ilUtil::sendFailure($this->lng->txt("select_one"), true);
1590 $this->ctrl->redirect($this, "editRaters");
1591 }
1592
1593 $a_form = $this->initMailRatersForm($appr_id, $_POST["rtr_id"]);
1594 }
1595
1596 $ilTabs->clearTargets();
1597 $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1598 $this->ctrl->getLinkTarget($this, "editRaters"));
1599
1600 $this->tpl->setContent($a_form->getHTML());
1601 }
1602
1604 {
1605 global $ilUser;
1606
1607 $appr_id = $this->handleRatersAccess();
1608 $this->ctrl->setParameter($this, "appr_id", $appr_id);
1609
1610 $rec_ids = explode(";", $_POST["rtr_id"]);
1611 if(!sizeof($rec_ids))
1612 {
1613 $this->ctrl->redirect($this, "editRaters");
1614 }
1615
1616 $form = $this->initMailRatersForm($appr_id, $rec_ids);
1617 if($form->checkInput())
1618 {
1619 $txt_u = $form->getInput("message_u");
1620 $txt_a = $form->getInput("message_a");
1621 $subj = $form->getInput("subject");
1622
1623 // #12743
1624 $sender_id = (trim($ilUser->getEmail()))
1625 ? $ilUser->getId()
1626 : ANONYMOUS_USER_ID;
1627
1628 include_once "./Services/Mail/classes/class.ilMail.php";
1629
1630 $all_data = $this->object->getRatersData($appr_id);
1631 foreach($rec_ids as $rec_id)
1632 {
1633 if(isset($all_data[$rec_id]))
1634 {
1635
1636 $user = $all_data[$rec_id];
1637
1638 // anonymous
1639 if(substr($rec_id, 0, 1) == "a")
1640 {
1641 $mytxt = $txt_a;
1642 $url = $user["href"];
1643 $rcp = $user["email"];
1644 }
1645 // reg
1646 else
1647 {
1648 $mytxt = $txt_u;
1649 $user["code"] = $this->lng->txt("survey_code_mail_on_demand");
1650 $url = ilLink::_getStaticLink($this->object->getRefId());
1651 $rcp = $user["login"]; // #15141
1652 }
1653
1654 $mytxt = str_replace("[lastname]", $user["lastname"], $mytxt);
1655 $mytxt = str_replace("[firstname]", $user["firstname"], $mytxt);
1656 $mytxt = str_replace("[url]", $url, $mytxt);
1657 $mytxt = str_replace("[code]", $user["code"], $mytxt);
1658
1659 $mail = new ilMail($sender_id);
1660 $mail->sendMail(
1661 $rcp, // to
1662 "", // cc
1663 "", // bcc
1664 $subj, // subject
1665 $mytxt, // message
1666 array(), // attachments
1667 array('normal') // type
1668 );
1669
1670 $this->object->set360RaterSent($appr_id,
1671 (substr($rec_id, 0, 1) == "a") ? 0 : (int)substr($rec_id, 1),
1672 (substr($rec_id, 0, 1) == "u") ? 0 : (int)substr($rec_id, 1));
1673 }
1674 }
1675
1676 ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
1677 $this->ctrl->redirect($this, "editRaters");
1678 }
1679
1680 $form->setValuesByPost();
1681 $this->mailRatersObject($form);
1682 }
1683
1685 {
1686 global $ilUser, $tpl, $ilTabs;
1687
1688 $ilTabs->clearTargets();
1689 $ilTabs->setBackTarget($this->lng->txt("menuback"),
1690 $this->ctrl->getLinkTarget($this->parent_gui, "infoScreen"));
1691
1692 if(!$this->object->isAppraisee($ilUser->getId()))
1693 {
1694 $this->ctrl->redirect($this->parent_gui, "infoScreen");
1695 }
1696
1697 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1698 $cgui = new ilConfirmationGUI();
1699 $cgui->setHeaderText($this->lng->txt("survey_360_sure_appraisee_close"));
1700
1701 $cgui->setFormAction($this->ctrl->getFormAction($this, "appraiseeClose"));
1702 $cgui->setCancel($this->lng->txt("cancel"), "confirmAppraiseeCloseCancel");
1703 $cgui->setConfirm($this->lng->txt("confirm"), "appraiseeClose");
1704
1705 $tpl->setContent($cgui->getHTML());
1706 }
1707
1709 {
1710 $this->ctrl->redirect($this->parent_gui, "infoScreen");
1711 }
1712
1714 {
1715 global $ilUser;
1716
1717 if(!$this->object->isAppraisee($ilUser->getId()))
1718 {
1719 $this->ctrl->redirect($this->parent_gui, "infoScreen");
1720 }
1721
1722 $this->object->closeAppraisee($ilUser->getId());
1723 ilUtil::sendSuccess($this->lng->txt("survey_360_appraisee_close_action_success"), true);
1724 $this->ctrl->redirect($this->parent_gui, "infoScreen");
1725 }
1726
1728 {
1729 global $tpl;
1730
1731 $this->parent_gui->handleWriteAccess();
1732
1733 $appr_ids = $_POST["appr_id"];
1734
1735 if(!sizeof($appr_ids))
1736 {
1737 ilUtil::sendFailure($this->lng->txt("select_one"), true);
1738 $this->ctrl->redirect($this, "listAppraisees");
1739 }
1740
1741 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1742 $cgui = new ilConfirmationGUI();
1743 $cgui->setHeaderText($this->lng->txt("survey_360_sure_appraisee_close_admin"));
1744
1745 $cgui->setFormAction($this->ctrl->getFormAction($this, "adminAppraiseesClose"));
1746 $cgui->setCancel($this->lng->txt("cancel"), "listAppraisees");
1747 $cgui->setConfirm($this->lng->txt("confirm"), "adminAppraiseesClose");
1748
1749 include_once "Services/User/classes/class.ilUserUtil.php";
1750 foreach($appr_ids as $appr_id)
1751 {
1752 $cgui->addItem("appr_id[]", $appr_id, ilUserUtil::getNamePresentation($appr_id));
1753 }
1754
1755 $tpl->setContent($cgui->getHTML());
1756 }
1757
1759 {
1760 $this->parent_gui->handleWriteAccess();
1761
1762 $appr_ids = $_POST["appr_id"];
1763
1764 if(!sizeof($appr_ids))
1765 {
1766 ilUtil::sendFailure($this->lng->txt("select_one"), true);
1767 $this->ctrl->redirect($this, "listAppraisees");
1768 }
1769
1770 $appr_data = $this->object->getAppraiseesData();
1771 foreach($appr_ids as $appr_id)
1772 {
1773 if(isset($appr_data[$appr_id]) && !$appr_data[$appr_id]["closed"])
1774 {
1775 $this->object->closeAppraisee($appr_id);
1776 }
1777 }
1778
1779 ilUtil::sendSuccess($this->lng->txt("survey_360_appraisee_close_action_success_admin"), true);
1780 $this->ctrl->redirect($this, "listAppraisees");
1781 }
1782
1783}
1784
1785?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
$_SESSION["AccountId"]
Class FormMailCodesGUI.
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
Confirmation screen class.
This class represents a custom property in a property form.
@classDescription Date and time handling
Class for single dates.
This class represents a file property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
Class Mail this class handles base functions for mail handling.
Class ilObjSurveyGUI.
const MODE_PREDEFINED_USERS
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
This class represents a selection list property in a property form.
ILIAS Setting Class.
Settings template application class.
static getInstance()
Factory.
Class ilSurveyParticipantsGUI.
exportCodesObject()
Exports a list of survey codes.
cancelDeleteAllUserDataObject()
Cancels delete of all user data in maintenance.
mailRatersObject(ilPropertyFormGUI $a_form=null)
saveInvitationStatusObject()
Saves the status of the invitation tab.
__construct(ilObjSurveyGUI $a_parent_gui)
deleteAllUserDataObject()
Creates a confirmation form for delete all user data.
setCodesSubtabs()
Set the tabs for the access codes section.
maintenanceObject()
Participants maintenance.
addExternalRaterFormObject(ilPropertyFormGUI $a_form=null)
inviteObject()
Creates the output for user/group invitation to a survey.
importAccessCodesActionObject()
Import codes from export codes file.
codesObject()
Display the survey access codes tab.
confirmDeleteAllUserDataObject()
Deletes all user data of the survey after confirmation.
createSurveyCodesObject()
Create access codes for the survey.
_convertCharset($a_string, $a_from_charset="", $a_to_charset="UTF-8")
exportAllCodesObject()
Exports all survey codes.
initMailRatersForm($appr_id, array $rec_ids)
deleteCodesObject()
Delete a list of survey codes.
disinviteUserGroupObject()
Disinvite users or groups from a survey.
deleteSingleUserResultsObject()
Asks for a confirmation to delete selected user data of the test object.
setCodeLanguageObject()
Change survey language for direct access URL's.
importAccessCodesObject()
Import codes from export codes file (upload form)
cancelDeleteSelectedUserDataObject()
Cancels the deletion of all user data for the test object.
inviteUserGroupObject($a_user_ids=array())
Invite users or groups to a survey.
confirmDeleteSelectedUserDataObject()
Deletes all user data for the test object.
This class represents a text area property in a property form.
This class represents a text property in a property form.
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:
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
$header
$data
$tbl
Definition: example_048.php:81
$code
Definition: example_050.php:99
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$url
Definition: shib_logout.php:72
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15