5 require_once
"./Services/Object/classes/class.ilObject2GUI.php";
40 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
44 $this->lng = $DIC->language();
45 $this->ctrl = $DIC->ctrl();
46 $this->help = $DIC[
"ilHelp"];
47 $this->tpl = $DIC[
"tpl"];
48 $this->tabs = $DIC->tabs();
49 $this->nav_history = $DIC[
"ilNavigationHistory"];
50 $this->toolbar = $DIC->toolbar();
51 $this->
user = $DIC->user();
52 $this->tree = $DIC->repositoryTree();
53 $this->locator = $DIC[
"ilLocator"];
54 $lng = $DIC->language();
55 $this->ui = $DIC->ui();
57 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
59 $lng->loadLanguageModule(
"poll");
71 ilUtil::sendSuccess($this->lng->txt(
"object_added"),
true);
72 $ilCtrl->redirect($this,
"render");
81 include_once
"Services/Object/classes/class.ilObjectActivation.php";
82 $this->lng->loadLanguageModule(
'rep');
85 $section->setTitle($this->lng->txt(
'rep_activation_availability'));
89 $act_obj_info = $act_ref_info =
"";
91 $act_obj_info =
' ' . $this->lng->txt(
'rep_activation_online_object_info');
92 $act_ref_info = $this->lng->txt(
'rep_activation_access_ref_info');
96 $online->
setInfo($this->lng->txt(
'poll_activation_online_info') . $act_obj_info);
99 include_once
"Services/Form/classes/class.ilDateDurationInputGUI.php";
108 $section->setTitle($this->lng->txt(
'poll_voting_period_and_results'));
118 $lng->txt(
"poll_view_results_always"),
122 $lng->txt(
"poll_view_results_never"),
126 $lng->txt(
"poll_view_results_after_vote"),
130 $lng->txt(
"poll_view_results_after_period"),
138 $lng->txt(
"poll_barchart"),
141 $show_result_as->addOption($result_bar);
143 $lng->txt(
"poll_piechart"),
146 $a_form->
addItem($show_result_as);
150 $sort->addOption(
new ilRadioOption(
$lng->txt(
"poll_result_sorting_answers"), 0));
155 $section->setTitle($this->lng->txt(
'poll_comments'));
165 include_once
"Services/Object/classes/class.ilObjectActivation.php";
167 $a_values[
"online"] = $this->
object->IsOnline();
168 $a_values[
"results"] = $this->
object->getViewResults();
169 $a_values[
"access_period"][
"start"] = $this->
object->getAccessBegin()
172 $a_values[
"access_period"][
"end"] = $this->
object->getAccessEnd()
175 $a_values[
"voting_period"][
"start"] = $this->
object->getVotingPeriodBegin()
178 $a_values[
"voting_period"][
"end"] = $this->
object->getVotingPeriodEnd()
181 $a_values[
"sort"] = $this->
object->getSortResultByVotes();
182 $a_values[
"comment"] = $this->
object->getShowComments();
183 $a_values[
"show_results_as"] = $this->
object->getShowResultsAs();
189 if (!$a_form->
getInput(
"voting_period") &&
192 $a_form->
getItemByPostVar(
"results")->setAlert($this->lng->txt(
"poll_view_results_after_period_impossible"));
195 return parent::validateCustom($a_form);
200 $this->
object->setViewResults($a_form->
getInput(
"results"));
201 $this->
object->setOnline($a_form->
getInput(
"online"));
202 $this->
object->setSortResultByVotes($a_form->
getInput(
"sort"));
203 $this->
object->setShowComments($a_form->
getInput(
"comment"));
204 $this->
object->setShowResultsAs($a_form->
getInput(
"show_results_as"));
206 include_once
"Services/Object/classes/class.ilObjectActivation.php";
208 if ($period->getStart() && $period->getEnd()) {
210 $this->
object->setAccessBegin($period->getStart()->get(
IL_CAL_UNIX));
211 $this->
object->setAccessEnd($period->getEnd()->get(
IL_CAL_UNIX));
217 if ($period->getStart() && $period->getEnd()) {
218 $this->
object->setVotingPeriod(1);
219 $this->
object->setVotingPeriodBegin($period->getStart()->get(
IL_CAL_UNIX));
220 $this->
object->setVotingPeriodEnd($period->getEnd()->get(
IL_CAL_UNIX));
222 $this->
object->setVotingPeriodBegin(null);
223 $this->
object->setVotingPeriodEnd(null);
224 $this->
object->setVotingPeriod(0);
233 $ilHelp->setScreenIdComponent(
"poll");
236 $this->tabs_gui->addTab(
238 $lng->txt(
"content"),
239 $this->ctrl->getLinkTarget($this,
"")
244 $this->tabs_gui->addTab(
246 $lng->txt(
"settings"),
247 $this->ctrl->getLinkTarget($this,
"edit")
250 $this->tabs_gui->addTab(
252 $lng->txt(
"poll_result"),
253 $this->ctrl->getLinkTarget($this,
"showParticipants")
256 $this->tabs_gui->addTab(
259 $this->ctrl->getLinkTargetByClass(
"ilexportgui",
"")
274 $next_class =
$ilCtrl->getNextClass($this);
277 $tpl->getStandardTemplate();
282 $link =
$ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"frameset");
283 $ilNavigationHistory->addItem($this->node_id, $link,
"poll");
286 switch ($next_class) {
287 case "ilinfoscreengui":
289 $this->infoScreenForward();
292 case "ilcommonactiondispatchergui":
293 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
295 $this->ctrl->forwardCommand($gui);
298 case "ilpermissiongui":
300 $ilTabs->activateTab(
"id_permissions");
301 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
303 $this->ctrl->forwardCommand($perm_gui);
306 case "ilobjectcopygui":
307 include_once
"./Services/Object/classes/class.ilObjectCopyGUI.php";
309 $cp->setType(
"poll");
310 $this->ctrl->forwardCommand($cp);
315 $ilTabs->activateTab(
"export");
316 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
318 $exp_gui->addFormat(
"xml");
319 $ilCtrl->forwardCommand($exp_gui);
323 return parent::executeCommand();
351 $ilTabs->activateTab(
"content");
354 if ($this->object->countVotes()) {
355 $url =
$ilCtrl->getLinkTarget($this,
"showParticipants");
357 $mbox =
$ui->factory()->messageBox()->info(
$lng->txt(
"poll_votes_no_edit"))
358 ->withLinks([
$ui->factory()->link()->standard(
359 $lng->txt(
"poll_result"),
369 $tpl->setPermanentLink(
'poll', $this->node_id);
379 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
381 $form->setFormAction(
$ilCtrl->getFormAction($this,
"saveQuestion"));
386 $question->setCols(40);
387 $question->setRows(2);
388 $question->setValue($this->object->getQuestion());
389 $question->setDisabled($a_read_only);
390 $form->addItem($question);
394 $img->setDisabled($a_read_only);
398 $file = $this->
object->getImageFullPath(
true);
400 $img->setImage($file);
406 $option->
setInfo(
$lng->txt(
"poll_mode_anonymous_info"));
407 $anonymous->addOption($option);
409 $option->
setInfo(
$lng->txt(
"poll_mode_personal_info"));
410 $anonymous->addOption($option);
411 $anonymous->setValue($this->object->getNonAnonymous());
412 $anonymous->setDisabled($a_read_only);
413 $form->addItem($anonymous);
417 $nanswers->setMinValue(1);
418 $nanswers->setSize(3);
419 $nanswers->setValue($this->object->getMaxNumberOfAnswers());
420 $nanswers->setDisabled($a_read_only);
421 $form->addItem($nanswers);
425 $answers->setMulti(
true,
true);
426 $answers->setDisabled($a_read_only);
427 $form->addItem($answers);
429 $multi_answers = array();
430 foreach ($this->object->getAnswers() as $idx => $item) {
432 $answers->setValue($item[
"answer"]);
434 $multi_answers[] = $item[
"answer"];
436 $answers->setMultiValues($multi_answers);
439 $form->addCommandButton(
"saveQuestion",
$lng->txt(
"save"));
448 if (
$form->checkInput()) {
449 $this->
object->setQuestion(
$form->getInput(
"question"));
450 $this->
object->setNonAnonymous(
$form->getInput(
"mode"));
452 $image =
$form->getItemByPostVar(
"image");
453 if ($_FILES[
"image"][
"tmp_name"]) {
454 $this->
object->uploadImage($_FILES[
"image"]);
455 } elseif ($image->getDeletionFlag()) {
456 $this->
object->deleteImage();
459 $nr_of_anwers = $this->
object->saveAnswers(
$form->getInput(
"answers"));
462 $this->
object->setMaxNumberOfAnswers(min(
$form->getInput(
"nanswers"), $nr_of_anwers));
464 if ($this->object->update()) {
465 ilUtil::sendSuccess($this->lng->txt(
"settings_saved"),
true);
466 $this->ctrl->redirect($this,
"render");
470 $form->setValuesByPost();
480 if (!$this->object->getNonAnonymous()) {
486 $lng->txt(
"poll_result_answers"),
487 $ilCtrl->getLinkTarget($this,
"showParticipants")
491 $lng->txt(
"poll_result_users"),
492 $ilCtrl->getLinkTarget($this,
"showParticipantVotes")
495 $ilTabs->activateSubTab($a_active);
509 $ilTabs->activateTab(
"participants");
512 include_once
"Modules/Poll/classes/class.ilPollAnswerTableGUI.php";
524 !$this->object->getNonAnonymous()) {
529 $ilTabs->activateTab(
"participants");
532 include_once
"Modules/Poll/classes/class.ilPollUserTableGUI.php";
548 $ilTabs->activateTab(
"participants");
550 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
552 $cgui->setHeaderText(
$lng->txt(
"poll_delete_votes_sure"));
554 $cgui->setFormAction($this->ctrl->getFormAction($this));
555 $cgui->setCancel(
$lng->txt(
"cancel"),
"showParticipants");
556 $cgui->setConfirm(
$lng->txt(
"confirm"),
"deleteAllVotes");
558 $tpl->setContent($cgui->getHTML());
571 $this->
object->deleteAllVotes();
573 $ilCtrl->redirect($this,
"showParticipants");
582 if ($this->object->getMaxNumberOfAnswers() > 1) {
583 if (
sizeof(
$_POST[
"aw"]) > $this->
object->getMaxNumberOfAnswers()) {
586 if (!
sizeof(
$_POST[
"aw"])) {
590 if ((
int) !
$_POST[
"aw"]) {
596 unset(
$_SESSION[
"last_poll_vote"][$this->object->getId()]);
604 include_once
"Services/Link/classes/class.ilLink.php";
614 include_once
"./Services/Notification/classes/class.ilNotification.php";
617 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
618 include_once
"Services/Link/classes/class.ilLink.php";
628 include_once
"./Services/Notification/classes/class.ilNotification.php";
631 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
632 include_once
"Services/Link/classes/class.ilLink.php";
641 include_once
"./Services/Notification/classes/class.ilNotification.php";
644 $this->object->getId(),
652 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
654 $ntf->setLangModules(array(
"poll"));
655 $ntf->setRefId($this->ref_id);
657 if ($this->object->getNonAnonymous()) {
658 $ntf->setChangedByUserId(
$ilUser->getId());
661 $ntf->setSubjectLangId(
'poll_vote_notification_subject');
662 $ntf->setIntroductionLangId(
'poll_vote_notification_body');
663 $ntf->setGotoLangId(
'poll_vote_notification_link');
664 $ntf->setReasonLangId(
'poll_vote_notification_reason');
666 $notified = $ntf->sendMail(
$users, null,
"read");
684 if (is_object($this->
object)) {
685 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$this->node_id);
694 public static function _goto($a_target)
698 $tree = $DIC->repositoryTree();
699 $ilAccess = $DIC->access();
701 $id = explode(
"_", $a_target);
705 if ($ilAccess->checkAccess(
"write",
"",
$ref_id)) {
706 $_GET[
"baseClass"] =
"ilRepositoryGUI";
708 $_GET[
"cmd"] =
"showParticipants";
709 include(
"ilias.php");
716 include_once
"Services/Link/classes/class.ilLink.php";
This class represents an option in a radio group.
const VIEW_RESULTS_AFTER_PERIOD
render($a_form=null)
Render object context.
const VIEW_RESULTS_AFTER_VOTE
setParticipantsSubTabs($a_active)
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
const VIEW_RESULTS_ALWAYS
getAccessHandler()
Get access handler.
const SHOW_RESULTS_AS_PIECHART
if(!array_key_exists('StateId', $_REQUEST)) $id
const TIMINGS_DEACTIVATED
static updateNotificationTime($type, $id, array $user_ids, $page_id=false)
Update the last mail timestamp for given object and users.
updateCustom(ilPropertyFormGUI $a_form)
initQuestionForm($a_read_only=false)
validateCustom(ilPropertyFormGUI $a_form)
setInfo($a_info)
Set Info.
getHTML()
return user view
static _getAllReferences($a_id)
get all reference ids of object
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
initEditCustomForm(ilPropertyFormGUI $a_form)
const SHOW_RESULTS_AS_BARCHART
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Export User Interface Class.
TableGUI class for poll answers.
catch(Exception $e) $message
if(isset($_POST['submit'])) $form
static _lookupObjId($a_id)
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a text area property in a property form.
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static redirect($a_script)
static _goto($a_target)
Deep link.
Wrapper classes for system notifications.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
afterSave(ilObject $a_new_object)
TableGUI class for poll users.
Confirmation screen class.
getEditFormCustomValues(array &$a_values)