ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  if($this->object->get360Mode())
108  {
109  return $this->listAppraiseesObject();
110  }
111 
112  $this->parent_gui->handleWriteAccess();
113  $this->setCodesSubtabs();
114 
115  if (DEVMODE && $_GET["fill"] > 0)
116  {
117  for ($i = 0; $i < $_GET["fill"]; $i++) $this->object->fillSurveyForUser();
118  }
119  include_once "./Modules/Survey/classes/tables/class.ilSurveyMaintenanceTableGUI.php";
120  $table_gui = new ilSurveyMaintenanceTableGUI($this, 'maintenance');
121  $total =& $this->object->getSurveyParticipants();
122  $data = array();
123  foreach ($total as $user_data)
124  {
125  $last_access = $this->object->_getLastAccess($user_data["active_id"]);
126  array_push($data, array(
127  'id' => $user_data["active_id"],
128  'name' => $user_data["sortname"],
129  'login' => $user_data["login"],
130  'last_access' => $last_access
131  ));
132  }
133  $table_gui->setData($data);
134  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
135  }
136 
142  function setCodesSubtabs()
143  {
144  global $ilTabs;
145 
146  // maintenance
147  $ilTabs->addSubTabTarget("results",
148  $this->ctrl->getLinkTarget($this,'maintenance'),
149  array("maintenance", "deleteAllUserData"),
150  "");
151 
152  // 360°
153  if($this->object->get360Mode())
154  {
155  $ilTabs->addSubTabTarget("survey_360_appraisees",
156  $this->ctrl->getLinkTarget($this,'listAppraisees'),
157  array("listAppraisees", "editRaters"),
158  "");
159  }
160 
161  $ilTabs->addSubTabTarget("codes",
162  $this->ctrl->getLinkTarget($this,'codes'),
163  array("codes", "editCodes", "createSurveyCodes", "setCodeLanguage", "deleteCodes", "exportCodes",
164  "importExternalMailRecipientsFromFileForm", "importExternalMailRecipientsFromTextForm"),
165  ""
166  );
167 
168  if(!$this->object->get360Mode())
169  {
170  // #12277 - invite
171  $ilTabs->addSubTabTarget("invitation",
172  $this->ctrl->getLinkTarget($this, 'invite'),
173  array("invite", "saveInvitationStatus",
174  "inviteUserGroup", "disinviteUserGroup"),
175  "");
176  }
177 
178  /*
179  $ilTabs->addSubTabTarget
180  (
181  "participating_users",
182  $this->ctrl->getLinkTarget($this, "codesMail"),
183  array("codesMail", "saveMailTableFields", "importExternalMailRecipients",
184  'importExternalRecipientsFromFile', 'importExternalRecipientsFromText',
185  'importExternalRecipientsFromDataset'),
186  ""
187  );
188  */
189 
190  $data = $this->object->getExternalCodeRecipients();
191  if (count($data))
192  {
193  $ilTabs->addSubTabTarget
194  (
195  "mail_survey_codes",
196  $this->ctrl->getLinkTarget($this, "mailCodes"),
197  array("mailCodes", "sendCodesMail", "insertSavedMessage", "deleteSavedMessage"),
198  ""
199  );
200  }
201  }
202 
206  public function disinviteUserGroupObject()
207  {
208  // disinvite users
209  if (is_array($_POST["user_select"]))
210  {
211  foreach ($_POST["user_select"] as $user_id)
212  {
213  $this->object->disinviteUser($user_id);
214  }
215  }
216  ilUtil::sendSuccess($this->lng->txt('msg_users_disinvited'), true);
217  $this->ctrl->redirect($this, "invite");
218  }
219 
223  public function inviteUserGroupObject($a_user_ids = array())
224  {
225  $invited = 0;
226  // add users to invitation
227  if (is_array($a_user_ids))
228  {
229  foreach ($a_user_ids as $user_id)
230  {
231  $this->object->inviteUser($user_id);
232  $invited++;
233  }
234  }
235  if ($invited == 0)
236  {
237  ilUtil::sendFailure($this->lng->txt('no_user_invited'), TRUE);
238  return false;
239  }
240  else
241  {
242  ilUtil::sendSuccess(sprintf($this->lng->txt('users_invited'), $invited), TRUE);
243  return false;
244  }
245  $this->ctrl->redirect($this, "invite");
246  }
247 
251  public function saveInvitationStatusObject()
252  {
253  $mode = $_POST['invitation'];
254  switch ($mode)
255  {
256  case 0:
257  $this->object->setInvitation(0);
258  break;
259  case 1:
260  $this->object->setInvitation(1);
261  $this->object->setInvitationMode(0);
262  break;
263  case 2:
264  $this->object->setInvitation(1);
265  $this->object->setInvitationMode(1);
266  break;
267  }
268  $this->object->saveToDb();
269  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
270  $this->ctrl->redirect($this, "invite");
271  }
272 
276  public function inviteObject()
277  {
278  global $ilAccess;
279  global $rbacsystem;
280  global $ilToolbar;
281  global $lng;
282 
283  $this->parent_gui->handleWriteAccess();
284  $this->setCodesSubtabs();
285 
286  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
287  $form = new ilPropertyFormGUI();
288  $form->setFormAction($this->ctrl->getFormAction($this));
289  $form->setTableWidth("500");
290  $form->setId("invite");
291 
292  // invitation
293  $header = new ilFormSectionHeaderGUI();
294  $header->setTitle($this->lng->txt("invitation"));
295  $form->addItem($header);
296 
297  // invitation mode
298  $invitation = new ilRadioGroupInputGUI($this->lng->txt('invitation_mode'), "invitation");
299  $invitation->setInfo($this->lng->txt('invitation_mode_desc'));
300  $invitation->addOption(new ilRadioOption($this->lng->txt("invitation_off"), 0, ''));
301  $surveySetting = new ilSetting("survey");
302  if ($surveySetting->get("unlimited_invitation"))
303  {
304  $invitation->addOption(new ilRadioOption($this->lng->txt("unlimited_users"), 1, ''));
305  }
306  $invitation->addOption(new ilRadioOption($this->lng->txt("predefined_users"), 2, ''));
307  $inv = 0;
308  if ($this->object->getInvitation())
309  {
310  $inv = $this->object->getInvitationMode() + 1;
311  }
312  $invitation->setValue($inv);
313  $form->addItem($invitation);
314 
315  $form->addCommandButton("saveInvitationStatus", $this->lng->txt("save"));
316 
317  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_invite.html", "Modules/Survey");
318  $this->tpl->setVariable("INVITATION_TABLE", $form->getHTML());
319 
320  if ($this->object->getInvitation() && $this->object->getInvitationMode() == 1)
321  {
322  // search button
323  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
325  $this,
326  $tb,
327  array(
328  'auto_complete_name' => $lng->txt('user'),
329  'submit_name' => $lng->txt('svy_invite_action')
330  )
331  );
332 
333  $ilToolbar->addSpacer();
334 
335  $ilToolbar->addButton($this->lng->txt("svy_search_users"),
336  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI',''));
337 
338  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
339 
340  $invited_users = $this->object->getUserData($this->object->getInvitedUsers());
341  include_once "./Modules/Survey/classes/tables/class.ilSurveyInvitedUsersTableGUI.php";
342  $table_gui = new ilSurveyInvitedUsersTableGUI($this, 'invite');
343  $table_gui->setData($invited_users);
344  $this->tpl->setVariable('TBL_INVITED_USERS', $table_gui->getHTML());
345  }
346  }
347 
351  public function deleteAllUserDataObject()
352  {
353  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
354  $cgui = new ilConfirmationGUI();
355  $cgui->setHeaderText($this->lng->txt("confirm_delete_all_user_data"));
356  $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteAllUserData"));
357  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteAllUserData");
358  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteAllUserData");
359  $this->tpl->setContent($cgui->getHTML());
360  }
361 
366  {
367  $this->object->deleteAllUserData();
368 
369  // #11558 - re-open closed appraisees
370  if($this->object->get360Mode())
371  {
372  $this->object->openAllAppraisees();
373  }
374 
375  ilUtil::sendSuccess($this->lng->txt("svy_all_user_data_deleted"), true);
376  $this->ctrl->redirect($this, "maintenance");
377  }
378 
383  {
384  $this->ctrl->redirect($this, "maintenance");
385  }
386 
391  {
392  $this->object->removeSelectedSurveyResults($_POST["chbUser"]);
393  ilUtil::sendSuccess($this->lng->txt("svy_selected_user_data_deleted"), true);
394  $this->ctrl->redirect($this, "maintenance");
395  }
396 
401  {
402  ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
403  $this->ctrl->redirect($this, "maintenance");
404  }
405 
410  {
411  $this->parent_gui->handleWriteAccess();
412 
413  if (count($_POST["chbUser"]) == 0)
414  {
415  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
416  $this->ctrl->redirect($this, "maintenance");
417  }
418 
419  ilUtil::sendQuestion($this->lng->txt("confirm_delete_single_user_data"));
420  include_once "./Modules/Survey/classes/tables/class.ilSurveyMaintenanceTableGUI.php";
421  $table_gui = new ilSurveyMaintenanceTableGUI($this, 'maintenance', true);
422  $total =& $this->object->getSurveyParticipants();
423  $data = array();
424  foreach ($total as $user_data)
425  {
426  if (in_array($user_data['active_id'], $_POST['chbUser']))
427  {
428  $last_access = $this->object->_getLastAccess($user_data["active_id"]);
429  array_push($data, array(
430  'id' => $user_data["active_id"],
431  'name' => $user_data["sortname"],
432  'login' => $user_data["login"],
433  'last_access' => $last_access
434  ));
435  }
436  }
437  $table_gui->setData($data);
438  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
439  }
440 
444  public function setCodeLanguageObject()
445  {
446  if (strcmp($_POST["lang"], "-1") != 0)
447  {
448  global $ilUser;
449  $ilUser->writePref("survey_code_language", $_POST["lang"]);
450  }
451  ilUtil::sendSuccess($this->lng->txt('language_changed'), true);
452  $this->ctrl->redirect($this, 'codes');
453  }
454 
458  public function codesObject()
459  {
460  global $ilUser, $ilToolbar;
461 
462  $this->parent_gui->handleWriteAccess();
463  $this->setCodesSubtabs();
464 
465  if ($this->object->getAnonymize() != 1 && !$this->object->isAccessibleWithCodeForAll())
466  {
467  return ilUtil::sendInfo($this->lng->txt("survey_codes_no_anonymization"));
468  }
469 
470  $default_lang = $ilUser->getPref("survey_code_language");
471 
472  // creation buttons
473  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
474 
475  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
476  $si = new ilTextInputGUI($this->lng->txt("new_survey_codes"), "nrOfCodes");
477  $si->setValue(1);
478  $si->setSize(3);
479  $ilToolbar->addInputItem($si, true);
480  $ilToolbar->addFormButton($this->lng->txt("create"), "createSurveyCodes");
481 
482  $ilToolbar->addSeparator();
483 
484  $ilToolbar->addFormButton($this->lng->txt("import_from_file"), "importExternalMailRecipientsFromFileForm");
485  $ilToolbar->addFormButton($this->lng->txt("import_from_text"), "importExternalMailRecipientsFromTextForm");
486 
487  $ilToolbar->addSeparator();
488 
489  $languages = $this->lng->getInstalledLanguages();
490  $options = array();
491  $this->lng->loadLanguageModule("meta");
492  foreach ($languages as $lang)
493  {
494  $options[$lang] = $this->lng->txt("meta_l_".$lang);
495  }
496  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
497  $si = new ilSelectInputGUI($this->lng->txt("survey_codes_lang"), "lang");
498  $si->setOptions($options);
499  $si->setValue($default_lang);
500  $ilToolbar->addInputItem($si, true);
501  $ilToolbar->addFormButton($this->lng->txt("set"), "setCodeLanguage");
502 
503 
504  include_once "./Modules/Survey/classes/tables/class.ilSurveyCodesTableGUI.php";
505  $table_gui = new ilSurveyCodesTableGUI($this, 'codes');
506  $survey_codes = $this->object->getSurveyCodesTableData(null, $default_lang);
507  $table_gui->setData($survey_codes);
508  $this->tpl->setContent($table_gui->getHTML());
509  }
510 
511  public function editCodesObject()
512  {
513  if(isset($_GET["new_ids"]))
514  {
515  $ids = explode(";", $_GET["new_ids"]);
516  }
517  else
518  {
519  $ids = (array)$_POST["chb_code"];
520  }
521  if(!$ids)
522  {
523  ilUtil::sendFailure($this->lng->txt('no_checkbox'), true);
524  $this->ctrl->redirect($this, 'codes');
525  }
526 
527  $this->parent_gui->handleWriteAccess();
528  $this->setCodesSubtabs();
529 
530  include_once "./Modules/Survey/classes/tables/class.ilSurveyCodesEditTableGUI.php";
531  $table_gui = new ilSurveyCodesEditTableGUI($this, 'editCodes');
532  $table_gui->setData($this->object->getSurveyCodesTableData($ids));
533  $this->tpl->setContent($table_gui->getHTML());
534  }
535 
536  public function updateCodesObject()
537  {
538  if(!is_array($_POST["chb_code"]))
539  {
540  $this->ctrl->redirect($this, 'codes');
541  }
542 
543  foreach($_POST["chb_code"] as $id)
544  {
545  $this->object->updateCode($id,
546  $_POST["chb_mail"][$id],
547  $_POST["chb_lname"][$id],
548  $_POST["chb_fname"][$id],
549  $_POST["chb_sent"][$id]
550  );
551  }
552 
553  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
554  $this->ctrl->redirect($this, 'codes');
555  }
556 
557  public function deleteCodesConfirmObject()
558  {
559  if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
560  {
561  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
562  $cgui = new ilConfirmationGUI();
563  $cgui->setHeaderText($this->lng->txt("survey_code_delete_sure"));
564 
565  $cgui->setFormAction($this->ctrl->getFormAction($this));
566  $cgui->setCancel($this->lng->txt("cancel"), "codes");
567  $cgui->setConfirm($this->lng->txt("confirm"), "deleteCodes");
568 
569  $data = $this->object->getSurveyCodesTableData($_POST["chb_code"]);
570 
571  foreach ($data as $item)
572  {
573  if($item["used"])
574  {
575  continue;
576  }
577 
578  $title = array($item["code"]);
579  $item["email"] ? $title[] = $item["email"] : null;
580  $item["last_name"] ? $title[] = $item["last_name"] : null;
581  $item["first_name"] ? $title[] = $item["first_name"] : null;
582  $title = implode(", ", $title);
583 
584  $cgui->addItem("chb_code[]", $item["code"], $title);
585  }
586 
587  $this->tpl->setContent($cgui->getHTML());
588  }
589  else
590  {
591  ilUtil::sendFailure($this->lng->txt('no_checkbox'), true);
592  $this->ctrl->redirect($this, 'codes');
593  }
594  }
595 
599  public function deleteCodesObject()
600  {
601  if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
602  {
603  foreach ($_POST["chb_code"] as $survey_code)
604  {
605  $this->object->deleteSurveyCode($survey_code);
606  }
607  ilUtil::sendSuccess($this->lng->txt('codes_deleted'), true);
608  }
609  else
610  {
611  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
612  }
613  $this->ctrl->redirect($this, 'codes');
614  }
615 
619  public function exportCodesObject()
620  {
621  if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
622  {
623  $export = $this->object->getSurveyCodesForExport(null, $_POST["chb_code"]);
624  ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".csv"));
625  }
626  else
627  {
628  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
629  $this->ctrl->redirect($this, 'codes');
630  }
631  }
632 
636  public function exportAllCodesObject()
637  {
638  $export = $this->object->getSurveyCodesForExport();
639  ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".csv"));
640  }
641 
645  public function createSurveyCodesObject()
646  {
647  if (is_numeric($_POST["nrOfCodes"]))
648  {
649  $ids = $this->object->createSurveyCodes($_POST["nrOfCodes"]);
650  ilUtil::sendSuccess($this->lng->txt('codes_created'), true);
651  $this->ctrl->setParameter($this, "new_ids", implode(";", $ids));
652  $this->ctrl->redirect($this, 'editCodes');
653  }
654  else
655  {
656  ilUtil::sendFailure($this->lng->txt("enter_valid_number_of_codes"), true);
657  $this->ctrl->redirect($this, 'codes');
658  }
659  }
660 
661  public function insertSavedMessageObject()
662  {
663  $this->parent_gui->handleWriteAccess();
664  $this->setCodesSubtabs();
665 
666  include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
667  $form_gui = new FormMailCodesGUI($this);
668  $form_gui->setValuesByPost();
669  try
670  {
671  if ($form_gui->getSavedMessages()->getValue() > 0)
672  {
673  global $ilUser;
674  $settings = $this->object->getUserSettings($ilUser->getId(), 'savemessage');
675  $form_gui->getMailMessage()->setValue($settings[$form_gui->getSavedMessages()->getValue()]['value']);
676  ilUtil::sendSuccess($this->lng->txt('msg_message_inserted'));
677  }
678  else
679  {
680  ilUtil::sendFailure($this->lng->txt('msg_no_message_inserted'));
681  }
682  }
683  catch (Exception $e)
684  {
685  global $ilLog;
686  $ilLog->write('Error: ' + $e->getMessage());
687  }
688  $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
689  }
690 
691  public function deleteSavedMessageObject()
692  {
693  $this->parent_gui->handleWriteAccess();
694  $this->setCodesSubtabs();
695 
696  include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
697  $form_gui = new FormMailCodesGUI($this);
698  $form_gui->setValuesByPost();
699  try
700  {
701  if ($form_gui->getSavedMessages()->getValue() > 0)
702  {
703  $this->object->deleteUserSettings($form_gui->getSavedMessages()->getValue());
704  $form_gui = new FormMailCodesGUI($this);
705  $form_gui->setValuesByPost();
706  ilUtil::sendSuccess($this->lng->txt('msg_message_deleted'));
707  }
708  else
709  {
710  ilUtil::sendFailure($this->lng->txt('msg_no_message_deleted'));
711  }
712  }
713  catch (Exception $e)
714  {
715  global $ilLog;
716  $ilLog->write('Error: ' + $e->getMessage());
717  }
718  $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
719  }
720 
721  public function mailCodesObject()
722  {
723  $this->parent_gui->handleWriteAccess();
724  $this->setCodesSubtabs();
725 
726  $mailData['m_subject'] = (array_key_exists('m_subject', $_POST)) ? $_POST['m_subject'] : sprintf($this->lng->txt('default_codes_mail_subject'), $this->object->getTitle());
727  $mailData['m_message'] = (array_key_exists('m_message', $_POST)) ? $_POST['m_message'] : $this->lng->txt('default_codes_mail_message');
728  $mailData['m_notsent'] = (array_key_exists('m_notsent', $_POST)) ? $_POST['m_notsent'] : '1';
729 
730  include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
731  $form_gui = new FormMailCodesGUI($this);
732  $form_gui->setValuesByArray($mailData);
733  $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
734  }
735 
736  public function sendCodesMailObject()
737  {
738  global $ilUser;
739 
740  $this->parent_gui->handleWriteAccess();
741  $this->setCodesSubtabs();
742 
743  include_once("./Modules/Survey/classes/forms/FormMailCodesGUI.php");
744  $form_gui = new FormMailCodesGUI($this);
745  if ($form_gui->checkInput())
746  {
747  $code_exists = strpos($_POST['m_message'], '[code]') !== FALSE;
748  if (!$code_exists)
749  {
750  if (!$code_exists) ilUtil::sendFailure($this->lng->txt('please_enter_mail_code'));
751  $form_gui->setValuesByPost();
752  }
753  else
754  {
755  if ($_POST['savemessage'] == 1)
756  {
757  global $ilUser;
758  $title = (strlen($_POST['savemessagetitle'])) ? $_POST['savemessagetitle'] : ilStr::substr($_POST['m_message'], 0, 40) . '...';
759  $this->object->saveUserSettings($ilUser->getId(), 'savemessage', $title, $_POST['m_message']);
760  }
761 
762  $lang = $ilUser->getPref("survey_code_language");
763  if(!$lang)
764  {
765  $lang = $this->lng->getDefaultLanguage();
766  }
767  $this->object->sendCodes($_POST['m_notsent'], $_POST['m_subject'], $_POST['m_message'],$lang);
768  ilUtil::sendSuccess($this->lng->txt('mail_sent'), true);
769  $this->ctrl->redirect($this, 'mailCodes');
770  }
771  }
772  else
773  {
774  $form_gui->setValuesByPost();
775  }
776  $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
777  }
778 
779  public function cancelCodesMailObject()
780  {
781  $this->ctrl->redirect($this, 'codesMail');
782  }
783 
785  {
786  if (!is_array($_POST['chb_ext']) || count(is_array($_POST['chb_ext'])) == 0)
787  {
788  ilUtil::sendInfo($this->lng->txt("err_no_selection"), true);
789  $this->ctrl->redirect($this, 'codesMail');
790  }
791  foreach ($_POST['chb_ext'] as $code)
792  {
793  $this->object->deleteSurveyCode($code);
794  }
795  ilUtil::sendSuccess($this->lng->txt('external_recipients_deleted'), true);
796  $this->ctrl->redirect($this, 'codesMail');
797  }
798 
800  {
801  if (trim($_POST['externaltext']))
802  {
803  $data = preg_split("/[\n\r]/", $_POST['externaltext']);
804  $fields = preg_split("/;/", array_shift($data));
805  if (!in_array('email', $fields))
806  {
807  $_SESSION['externaltext'] = $_POST['externaltext'];
808  ilUtil::sendFailure($this->lng->txt('err_external_rcp_no_email_column'), true);
809  $this->ctrl->redirect($this, 'importExternalMailRecipientsFromTextForm');
810  }
811  $existingdata = $this->object->getExternalCodeRecipients();
812  $existingcolumns = array();
813  if (count($existingdata))
814  {
815  $first = array_shift($existingdata);
816  foreach ($first as $key => $value)
817  {
818  array_push($existingcolumns, $key);
819  }
820  }
821  $founddata = array();
822  foreach ($data as $datarow)
823  {
824  $row = preg_split("/;/", $datarow);
825  if (count($row) == count($fields))
826  {
827  $dataset = array();
828  foreach ($fields as $idx => $fieldname)
829  {
830  if (count($existingcolumns))
831  {
832  if (array_key_exists($idx, $existingcolumns))
833  {
834  $dataset[$fieldname] = $row[$idx];
835  }
836  }
837  else
838  {
839  $dataset[$fieldname] = $row[$idx];
840  }
841  }
842  if (strlen($dataset['email']))
843  {
844  array_push($founddata, $dataset);
845  }
846  }
847  }
848  $this->object->createSurveyCodesForExternalData($founddata);
849  ilUtil::sendSuccess($this->lng->txt('external_recipients_imported'), true);
850  $this->ctrl->redirect($this, 'codes');
851  }
852 
853  $this->ctrl->redirect($this, 'importExternalMailRecipientsFromTextForm');
854  }
855 
857  {
858  if (trim($_FILES['externalmails']['tmp_name']))
859  {
860  include_once "./Services/Utilities/classes/class.ilCSVReader.php";
861  $reader = new ilCSVReader();
862  $reader->open($_FILES['externalmails']['tmp_name']);
863  $data = $reader->getDataArrayFromCSVFile();
864  $fields = array_shift($data);
865  if (!in_array('email', $fields))
866  {
867  $reader->close();
868  ilUtil::sendFailure($this->lng->txt('err_external_rcp_no_email'), true);
869  $this->ctrl->redirect($this, 'codes');
870  }
871  $existingdata = $this->object->getExternalCodeRecipients();
872  $existingcolumns = array();
873  if (count($existingdata))
874  {
875  $first = array_shift($existingdata);
876  foreach ($first as $key => $value)
877  {
878  array_push($existingcolumns, $key);
879  }
880  }
881  $founddata = array();
882  foreach ($data as $row)
883  {
884  if (count($row) == count($fields))
885  {
886  $dataset = array();
887  foreach ($fields as $idx => $fieldname)
888  {
889  if (count($existingcolumns))
890  {
891  if (array_key_exists($idx, $existingcolumns))
892  {
893  $dataset[$fieldname] = $row[$idx];
894  }
895  }
896  else
897  {
898  $dataset[$fieldname] = $row[$idx];
899  }
900  }
901  if (strlen($dataset['email']))
902  {
903  array_push($founddata, $dataset);
904  }
905  }
906  }
907  $reader->close();
908  $this->object->createSurveyCodesForExternalData($founddata);
909  ilUtil::sendSuccess($this->lng->txt('external_recipients_imported'), true);
910  $this->ctrl->redirect($this, 'codes');
911  }
912 
913  $this->ctrl->redirect($this, 'importExternalMailRecipientsFromTextForm');
914  }
915 
917  {
918  global $ilAccess;
919 
920  $this->parent_gui->handleWriteAccess();
921  $this->setCodesSubtabs();
922 
923  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
924  $form_import_file = new ilPropertyFormGUI();
925  $form_import_file->setFormAction($this->ctrl->getFormAction($this));
926  $form_import_file->setTableWidth("100%");
927  $form_import_file->setId("codes_import_file");
928 
929  $headerfile = new ilFormSectionHeaderGUI();
930  $headerfile->setTitle($this->lng->txt("import_from_file"));
931  $form_import_file->addItem($headerfile);
932 
933  $externalmails = new ilFileInputGUI($this->lng->txt("externalmails"), "externalmails");
934  $externalmails->setInfo($this->lng->txt('externalmails_info'));
935  $externalmails->setRequired(true);
936  $form_import_file->addItem($externalmails);
937  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_file->addCommandButton("importExternalRecipientsFromFile", $this->lng->txt("import"));
938  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_file->addCommandButton("codes", $this->lng->txt("cancel"));
939 
940  $this->tpl->setContent($form_import_file->getHTML());
941  }
942 
944  {
945  global $ilAccess;
946 
947  $this->parent_gui->handleWriteAccess();
948  $this->setCodesSubtabs();
949 
950  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
951  $form_import_text = new ilPropertyFormGUI();
952  $form_import_text->setFormAction($this->ctrl->getFormAction($this));
953  $form_import_text->setTableWidth("100%");
954  $form_import_text->setId("codes_import_text");
955 
956  $headertext = new ilFormSectionHeaderGUI();
957  $headertext->setTitle($this->lng->txt("import_from_text"));
958  $form_import_text->addItem($headertext);
959 
960  $inp = new ilTextAreaInputGUI($this->lng->txt('externaltext'), 'externaltext');
961  if (array_key_exists('externaltext', $_SESSION) && strlen($_SESSION['externaltext']))
962  {
963  $inp->setValue($_SESSION['externaltext']);
964  }
965  else
966  {
967  $inp->setValue($this->lng->txt('mail_import_example1') . "\n" . $this->lng->txt('mail_import_example2') . "\n" . $this->lng->txt('mail_import_example3') . "\n");
968  }
969  $inp->setRequired(true);
970  $inp->setCols(80);
971  $inp->setRows(10);
972  $inp->setInfo($this->lng->txt('externaltext_info'));
973  $form_import_text->addItem($inp);
974  unset($_SESSION['externaltext']);
975 
976  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_text->addCommandButton("importExternalRecipientsFromText", $this->lng->txt("import"));
977  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form_import_text->addCommandButton("codes", $this->lng->txt("cancel"));
978 
979  $this->tpl->setContent($form_import_text->getHTML());
980  }
981 
982 
983 
984 
985 
986 
987 
988 
989 
990 
991  //
992  // 360°
993  //
994 
995 
996 
997 
998  public function listAppraiseesObject()
999  {
1000  global $ilToolbar, $lng, $ilCtrl;
1001 
1002  $this->parent_gui->handleWriteAccess();
1003  // $this->setCodesSubtabs();
1004 
1005  $this->ctrl->setParameter($this, "appr360", 1);
1006 
1007  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1009  $this,
1010  $ilToolbar,
1011  array(
1012  'auto_complete_name' => $this->lng->txt('user'),
1013  'submit_name' => $this->lng->txt('add'),
1014  'add_search' => true,
1015  'add_from_container' => $this->ref_id
1016  )
1017  );
1018 
1019  // competence calculations
1020  include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
1021  $skmg_set = new ilSkillManagementSettings();
1022  if ($this->object->get360SkillService() && $skmg_set->isActivated())
1023  {
1024  $ilToolbar->addSeparator();
1025  $ilToolbar->addButton($lng->txt("survey_calc_skills"),
1026  $ilCtrl->getLinkTargetByClass("ilsurveyskilldeterminationgui"), "");
1027  }
1028 
1029 
1030  $this->ctrl->setParameter($this, "appr360", "");
1031 
1032  include_once "Modules/Survey/classes/tables/class.ilSurveyAppraiseesTableGUI.php";
1033  $tbl = new ilSurveyAppraiseesTableGUI($this, "listAppraisees");
1034  $tbl->setData($this->object->getAppraiseesData());
1035  $this->tpl->setContent($tbl->getHTML());
1036  }
1037 
1038  public function addAppraisee($a_user_ids)
1039  {
1040  if(sizeof($a_user_ids))
1041  {
1042  // #13319
1043  foreach(array_unique($a_user_ids) as $user_id)
1044  {
1045  $this->object->addAppraisee($user_id);
1046  }
1047 
1048  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1049  }
1050  $this->ctrl->redirect($this, "listAppraisees");
1051  }
1052 
1054  {
1055  global $ilTabs;
1056 
1057  if(!sizeof($_POST["appr_id"]))
1058  {
1059  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1060  $this->ctrl->redirect($this, "listAppraisees");
1061  }
1062 
1063  $ilTabs->clearTargets();
1064  $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1065  $this->ctrl->getLinkTarget($this, "listAppraisees"));
1066 
1067  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1068  $cgui = new ilConfirmationGUI();
1069  $cgui->setHeaderText($this->lng->txt("survey_360_sure_delete_appraises"));
1070 
1071  $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteAppraisees"));
1072  $cgui->setCancel($this->lng->txt("cancel"), "listAppraisees");
1073  $cgui->setConfirm($this->lng->txt("confirm"), "deleteAppraisees");
1074 
1075  $data = $this->object->getAppraiseesData();
1076 
1077  $count = 0;
1078  include_once "Services/User/classes/class.ilUserUtil.php";
1079  foreach ($_POST["appr_id"] as $id)
1080  {
1081  if(isset($data[$id]) && !$data[$id]["closed"])
1082  {
1083  $cgui->addItem("appr_id[]", $id, ilUserUtil::getNamePresentation($id));
1084  $count++;
1085  }
1086  }
1087 
1088  if(!$count)
1089  {
1090  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1091  $this->ctrl->redirect($this, "listAppraisees");
1092  }
1093 
1094  $this->tpl->setContent($cgui->getHTML());
1095  }
1096 
1097  public function deleteAppraiseesObject()
1098  {
1099  if(sizeof($_POST["appr_id"]))
1100  {
1101  $data = $this->object->getAppraiseesData();
1102 
1103  foreach ($_POST["appr_id"] as $id)
1104  {
1105  // #11285
1106  if(isset($data[$id]) && !$data[$id]["closed"])
1107  {
1108  $this->object->deleteAppraisee($id);
1109  }
1110  }
1111 
1112  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1113  }
1114 
1115  $this->ctrl->redirect($this, "listAppraisees");
1116  }
1117 
1119  {
1120  global $ilAccess, $ilUser;
1121 
1122  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1123  {
1124  $appr_id = $_REQUEST["appr_id"];
1125  if(!$appr_id)
1126  {
1127  $this->ctrl->redirect($this, "listAppraisees");
1128  }
1129  return $appr_id;
1130  }
1131  else if($this->object->get360Mode() &&
1132  $this->object->get360SelfRaters() &&
1133  $this->object->isAppraisee($ilUser->getId()) &&
1134  !$this->object->isAppraiseeClosed($ilUser->getId()))
1135  {
1136  return $ilUser->getId();
1137  }
1138  $this->ctrl->redirect($this->parent_gui, "infoScreen");
1139  }
1140 
1141  public function editRatersObject()
1142  {
1143  global $ilTabs, $ilToolbar, $ilAccess;
1144 
1145  $appr_id = $_REQUEST["appr_id"] = $this->handleRatersAccess();
1146 
1147  $has_write = $ilAccess->checkAccess("write", "", $this->ref_id);
1148  if($has_write)
1149  {
1150  $ilTabs->clearTargets();
1151  $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1152  $this->ctrl->getLinkTarget($this, "listAppraisees"));
1153  }
1154 
1155  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1156  $this->ctrl->setParameter($this, "rate360", 1);
1157 
1158  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1160  $this,
1161  $ilToolbar,
1162  array(
1163  'auto_complete_name' => $this->lng->txt('user'),
1164  'submit_name' => $this->lng->txt('add'),
1165  'add_search' => true,
1166  'add_from_container' => $this->ref_id
1167  )
1168  );
1169 
1170  $this->ctrl->setParameter($this, "rate360", "");
1171 
1172  $ilToolbar->addSeparator();
1173 
1174  $ilToolbar->addButton($this->lng->txt("survey_360_add_external_rater"),
1175  $this->ctrl->getLinkTarget($this, "addExternalRaterForm"));
1176 
1177  include_once "Modules/Survey/classes/tables/class.ilSurveyAppraiseesTableGUI.php";
1178  $tbl = new ilSurveyAppraiseesTableGUI($this, "editRaters", true, !$this->object->isAppraiseeClosed($appr_id)); // #11285
1179  $tbl->setData($this->object->getRatersData($appr_id));
1180  $this->tpl->setContent($tbl->getHTML());
1181  }
1182 
1183  public function addExternalRaterFormObject(ilPropertyFormGUI $a_form = null)
1184  {
1185  global $ilTabs, $ilAccess;
1186 
1187  $appr_id = $this->handleRatersAccess();
1188  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1189 
1190  $has_write = $ilAccess->checkAccess("write", "", $this->ref_id);
1191  if($has_write)
1192  {
1193  $ilTabs->clearTargets();
1194  $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1195  $this->ctrl->getLinkTarget($this, "editRaters"));
1196  }
1197 
1198  if(!$a_form)
1199  {
1200  $a_form = $this->initExternalRaterForm($appr_id);
1201  }
1202 
1203  $this->tpl->setContent($a_form->getHTML());
1204  }
1205 
1206  protected function initExternalRaterForm($appr_id)
1207  {
1208  include_once "Services/User/classes/class.ilUserUtil.php";
1209  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1210  $form = new ilPropertyFormGUI();
1211  $form->setFormAction($this->ctrl->getFormAction($this, "addExternalRater"));
1212  $form->setTitle($this->lng->txt("survey_360_add_external_rater").
1213  ": ".ilUserUtil::getNamePresentation($appr_id));
1214 
1215  $email = new ilEmailInputGUI($this->lng->txt("email"), "email");
1216  $email->setRequired(true);
1217  $form->addItem($email);
1218 
1219  $lname = new ilTextInputGUI($this->lng->txt("lastname"), "lname");
1220  $lname->setSize(30);
1221  $form->addItem($lname);
1222 
1223  $fname = new ilTextInputGUI($this->lng->txt("firstname"), "fname");
1224  $fname->setSize(30);
1225  $form->addItem($fname);
1226 
1227  $form->addCommandButton("addExternalRater", $this->lng->txt("save"));
1228  $form->addCommandButton("editRaters", $this->lng->txt("cancel"));
1229 
1230  return $form;
1231  }
1232 
1233  public function addExternalRaterObject()
1234  {
1235  $appr_id = $_REQUEST["appr_id"];
1236  if(!$appr_id)
1237  {
1238  $this->ctrl->redirect($this, "listAppraisees");
1239  }
1240 
1241  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1242 
1243  $form = $this->initExternalRaterForm($appr_id);
1244  if($form->checkInput())
1245  {
1246  $data = array(
1247  "email" => $form->getInput("email"),
1248  "lastname" => $form->getInput("lname"),
1249  "firstname" => $form->getInput("fname")
1250  );
1251  $anonymous_id = $this->object->createSurveyCodesForExternalData(array($data));
1252  $anonymous_id = array_pop($anonymous_id);
1253 
1254  $this->object->addRater($appr_id, 0, $anonymous_id);
1255 
1256  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1257  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1258  $this->ctrl->redirect($this, "editRaters");
1259  }
1260 
1261  $form->setValuesByPost();
1262  $this->addExternalRaterFormObject($form);
1263  }
1264 
1265  public function addRater($a_user_ids)
1266  {
1267  global $ilAccess, $ilUser;
1268 
1269  $appr_id = $this->handleRatersAccess();
1270 
1271  if(sizeof($a_user_ids))
1272  {
1273  // #13319
1274  foreach(array_unique($a_user_ids) as $user_id)
1275  {
1276  if($ilAccess->checkAccess("write", "", $this->ref_id) ||
1277  $this->object->get360SelfEvaluation() ||
1278  $user_id != $ilUser->getId())
1279  {
1280  $this->object->addRater($appr_id, $user_id);
1281  }
1282  }
1283 
1284  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1285  }
1286 
1287  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1288  $this->ctrl->redirect($this, "editRaters");
1289  }
1290 
1291  public function confirmDeleteRatersObject()
1292  {
1293  global $ilTabs;
1294 
1295  $appr_id = $this->handleRatersAccess();
1296  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1297  if(!sizeof($_POST["rtr_id"]))
1298  {
1299  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1300  $this->ctrl->redirect($this, "editRaters");
1301  }
1302 
1303  $ilTabs->clearTargets();
1304  $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1305  $this->ctrl->getLinkTarget($this, "editRaters"));
1306 
1307  include_once "Services/User/classes/class.ilUserUtil.php";
1308  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1309  $cgui = new ilConfirmationGUI();
1310  $cgui->setHeaderText(sprintf($this->lng->txt("survey_360_sure_delete_raters"),
1311  ilUserUtil::getNamePresentation($appr_id)));
1312 
1313  $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteRaters"));
1314  $cgui->setCancel($this->lng->txt("cancel"), "editRaters");
1315  $cgui->setConfirm($this->lng->txt("confirm"), "deleteRaters");
1316 
1317  $data = $this->object->getRatersData($appr_id);
1318 
1319  foreach ($_POST["rtr_id"] as $id)
1320  {
1321  if(isset($data[$id]))
1322  {
1323  $cgui->addItem("rtr_id[]", $id, $data[$id]["lastname"].", ".
1324  $data[$id]["firstname"]." (".$data[$id]["email"].")");
1325  }
1326  }
1327 
1328  $this->tpl->setContent($cgui->getHTML());
1329  }
1330 
1331  public function deleteRatersObject()
1332  {
1333  $appr_id = $this->handleRatersAccess();
1334  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1335 
1336  if(sizeof($_POST["rtr_id"]))
1337  {
1338  $data = $this->object->getRatersData($appr_id);
1339 
1340  foreach ($_POST["rtr_id"] as $id)
1341  {
1342  if(isset($data[$id]))
1343  {
1344  if(substr($id, 0, 1) == "u")
1345  {
1346  $this->object->deleteRater($appr_id, substr($id, 1));
1347  }
1348  else
1349  {
1350  $this->object->deleteRater($appr_id, 0, substr($id, 1));
1351  }
1352  }
1353  }
1354 
1355  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1356  }
1357 
1358  $this->ctrl->redirect($this, "editRaters");
1359  }
1360 
1362  {
1363  global $ilUser;
1364 
1365  if($this->object->get360SelfAppraisee() &&
1366  !$this->object->isAppraisee($ilUser->getId()))
1367  {
1368  $this->object->addAppraisee($ilUser->getId());
1369  }
1370 
1371  $this->ctrl->redirect($this->parent_gui, "infoScreen");
1372  }
1373 
1374  function initMailRatersForm($appr_id, array $rec_ids)
1375  {
1376  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1377  $form = new ilPropertyFormGUI();
1378  $form->setFormAction($this->ctrl->getFormAction($this, "mailRatersAction"));
1379  $form->setTitle($this->lng->txt('compose'));
1380 
1381  $all_data = $this->object->getRatersData($appr_id);
1382  $rec_data = array();
1383  foreach($rec_ids as $rec_id)
1384  {
1385  if(isset($all_data[$rec_id]))
1386  {
1387  $rec_data[] = $all_data[$rec_id]["lastname"].", ".
1388  $all_data[$rec_id]["firstname"].
1389  " (".$all_data[$rec_id]["email"].")";
1390  }
1391  }
1392  sort($rec_data);
1393  $rec = new ilCustomInputGUI($this->lng->txt('recipients'));
1394  $rec->setHTML(implode("<br />", $rec_data));
1395  $form->addItem($rec);
1396 
1397  $subject = new ilTextInputGUI($this->lng->txt('subject'), 'subject');
1398  $subject->setSize(50);
1399  $subject->setRequired(true);
1400  $form->addItem($subject);
1401 
1402  $existingdata = $this->object->getExternalCodeRecipients();
1403  $existingcolumns = array();
1404  if (count($existingdata))
1405  {
1406  $first = array_shift($existingdata);
1407  foreach ($first as $key => $value)
1408  {
1409  if (strcmp($key, 'code') != 0 && strcmp($key, 'email') != 0 && strcmp($key, 'sent') != 0) array_push($existingcolumns, '[' . $key . ']');
1410  }
1411  }
1412 
1413  $mailmessage_u = new ilTextAreaInputGUI($this->lng->txt('survey_360_rater_message_content_registered'), 'message_u');
1414  $mailmessage_u->setRequired(true);
1415  $mailmessage_u->setCols(80);
1416  $mailmessage_u->setRows(10);
1417  $form->addItem($mailmessage_u);
1418 
1419  $mailmessage_a = new ilTextAreaInputGUI($this->lng->txt('survey_360_rater_message_content_anonymous'), 'message_a');
1420  $mailmessage_a->setRequired(true);
1421  $mailmessage_a->setCols(80);
1422  $mailmessage_a->setRows(10);
1423  $mailmessage_a->setInfo(sprintf($this->lng->txt('message_content_info'), join($existingcolumns, ', ')));
1424  $form->addItem($mailmessage_a);
1425 
1426  $recf = new ilHiddenInputGUI("rtr_id");
1427  $recf->setValue(implode(";", $rec_ids));
1428  $form->addItem($recf);
1429 
1430  $form->addCommandButton("mailRatersAction", $this->lng->txt("send"));
1431  $form->addCommandButton("editRaters", $this->lng->txt("cancel"));
1432 
1433  $subject->setValue(sprintf($this->lng->txt('survey_360_rater_subject_default'), $this->object->getTitle()));
1434  $mailmessage_u->setValue($this->lng->txt('survey_360_rater_message_content_registered_default'));
1435  $mailmessage_a->setValue($this->lng->txt('survey_360_rater_message_content_anonymous_default'));
1436 
1437  return $form;
1438  }
1439 
1440  function mailRatersObject(ilPropertyFormGUI $a_form = null)
1441  {
1442  global $ilTabs;
1443 
1444  if(!$a_form)
1445  {
1446  $appr_id = $this->handleRatersAccess();
1447  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1448 
1449  if(!sizeof($_POST["rtr_id"]))
1450  {
1451  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1452  $this->ctrl->redirect($this, "editRaters");
1453  }
1454 
1455  $a_form = $this->initMailRatersForm($appr_id, $_POST["rtr_id"]);
1456  }
1457 
1458  $ilTabs->clearTargets();
1459  $ilTabs->setBackTarget($this->lng->txt("btn_back"),
1460  $this->ctrl->getLinkTarget($this, "editRaters"));
1461 
1462  $this->tpl->setContent($a_form->getHTML());
1463  }
1464 
1466  {
1467  global $ilUser;
1468 
1469  $appr_id = $this->handleRatersAccess();
1470  $this->ctrl->setParameter($this, "appr_id", $appr_id);
1471 
1472  $rec_ids = explode(";", $_POST["rtr_id"]);
1473  if(!sizeof($rec_ids))
1474  {
1475  $this->ctrl->redirect($this, "editRaters");
1476  }
1477 
1478  $form = $this->initMailRatersForm($appr_id, $rec_ids);
1479  if($form->checkInput())
1480  {
1481  $txt_u = $form->getInput("message_u");
1482  $txt_a = $form->getInput("message_a");
1483  $subj = $form->getInput("subject");
1484 
1485  // #12743
1486  $sender_id = (trim($ilUser->getEmail()))
1487  ? $ilUser->getId()
1488  : ANONYMOUS_USER_ID;
1489 
1490  include_once "./Services/Mail/classes/class.ilMail.php";
1491 
1492  $all_data = $this->object->getRatersData($appr_id);
1493  foreach($rec_ids as $rec_id)
1494  {
1495  if(isset($all_data[$rec_id]))
1496  {
1497 
1498  $user = $all_data[$rec_id];
1499 
1500  // anonymous
1501  if(substr($rec_id, 0, 1) == "a")
1502  {
1503  $mytxt = $txt_a;
1504  $url = $user["href"];
1505  $rcp = $user["email"];
1506  }
1507  // reg
1508  else
1509  {
1510  $mytxt = $txt_u;
1511  $user["code"] = $this->lng->txt("survey_code_mail_on_demand");
1512  $url = ilLink::_getStaticLink($this->object->getRefId());
1513  $rcp = $user["login"]; // #15141
1514  }
1515 
1516  $mytxt = str_replace("[lastname]", $user["lastname"], $mytxt);
1517  $mytxt = str_replace("[firstname]", $user["firstname"], $mytxt);
1518  $mytxt = str_replace("[url]", $url, $mytxt);
1519  $mytxt = str_replace("[code]", $user["code"], $mytxt);
1520 
1521  $mail = new ilMail($sender_id);
1522  $mail->sendMail(
1523  $rcp, // to
1524  "", // cc
1525  "", // bcc
1526  $subj, // subject
1527  $mytxt, // message
1528  array(), // attachments
1529  array('normal') // type
1530  );
1531 
1532  $this->object->set360RaterSent($appr_id,
1533  (substr($rec_id, 0, 1) == "a") ? 0 : (int)substr($rec_id, 1),
1534  (substr($rec_id, 0, 1) == "u") ? 0 : (int)substr($rec_id, 1));
1535  }
1536  }
1537 
1538  ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
1539  $this->ctrl->redirect($this, "editRaters");
1540  }
1541 
1542  $form->setValuesByPost();
1543  $this->mailRatersObject($form);
1544  }
1545 
1547  {
1548  global $ilUser, $tpl, $ilTabs;
1549 
1550  $ilTabs->clearTargets();
1551  $ilTabs->setBackTarget($this->lng->txt("menuback"),
1552  $this->ctrl->getLinkTarget($this->parent_gui, "infoScreen"));
1553 
1554  if(!$this->object->isAppraisee($ilUser->getId()))
1555  {
1556  $this->ctrl->redirect($this->parent_gui, "infoScreen");
1557  }
1558 
1559  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1560  $cgui = new ilConfirmationGUI();
1561  $cgui->setHeaderText($this->lng->txt("survey_360_sure_appraisee_close"));
1562 
1563  $cgui->setFormAction($this->ctrl->getFormAction($this, "appraiseeClose"));
1564  $cgui->setCancel($this->lng->txt("cancel"), "confirmAppraiseeCloseCancel");
1565  $cgui->setConfirm($this->lng->txt("confirm"), "appraiseeClose");
1566 
1567  $tpl->setContent($cgui->getHTML());
1568  }
1569 
1571  {
1572  $this->ctrl->redirect($this->parent_gui, "infoScreen");
1573  }
1574 
1576  {
1577  global $ilUser;
1578 
1579  if(!$this->object->isAppraisee($ilUser->getId()))
1580  {
1581  $this->ctrl->redirect($this->parent_gui, "infoScreen");
1582  }
1583 
1584  $this->object->closeAppraisee($ilUser->getId());
1585  ilUtil::sendSuccess($this->lng->txt("survey_360_appraisee_close_action_success"), true);
1586  $this->ctrl->redirect($this->parent_gui, "infoScreen");
1587  }
1588 
1590  {
1591  global $tpl;
1592 
1593  $this->parent_gui->handleWriteAccess();
1594 
1595  $appr_ids = $_POST["appr_id"];
1596 
1597  if(!sizeof($appr_ids))
1598  {
1599  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1600  $this->ctrl->redirect($this, "listAppraisees");
1601  }
1602 
1603  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1604  $cgui = new ilConfirmationGUI();
1605  $cgui->setHeaderText($this->lng->txt("survey_360_sure_appraisee_close_admin"));
1606 
1607  $cgui->setFormAction($this->ctrl->getFormAction($this, "adminAppraiseesClose"));
1608  $cgui->setCancel($this->lng->txt("cancel"), "listAppraisees");
1609  $cgui->setConfirm($this->lng->txt("confirm"), "adminAppraiseesClose");
1610 
1611  include_once "Services/User/classes/class.ilUserUtil.php";
1612  foreach($appr_ids as $appr_id)
1613  {
1614  $cgui->addItem("appr_id[]", $appr_id, ilUserUtil::getNamePresentation($appr_id));
1615  }
1616 
1617  $tpl->setContent($cgui->getHTML());
1618  }
1619 
1621  {
1622  $this->parent_gui->handleWriteAccess();
1623 
1624  $appr_ids = $_POST["appr_id"];
1625 
1626  if(!sizeof($appr_ids))
1627  {
1628  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1629  $this->ctrl->redirect($this, "listAppraisees");
1630  }
1631 
1632  $appr_data = $this->object->getAppraiseesData();
1633  foreach($appr_ids as $appr_id)
1634  {
1635  if(isset($appr_data[$appr_id]) && !$appr_data[$appr_id]["closed"])
1636  {
1637  $this->object->closeAppraisee($appr_id);
1638  }
1639  }
1640 
1641  ilUtil::sendSuccess($this->lng->txt("survey_360_appraisee_close_action_success_admin"), true);
1642  $this->ctrl->redirect($this, "listAppraisees");
1643  }
1644 
1645 }
1646 
1647 ?>