5require_once
"./Services/Object/classes/class.ilObject2GUI.php";
20 function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
24 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
26 $lng->loadLanguageModule(
"poll");
39 $ilCtrl->redirect($this,
"render");
48 include_once
"Services/Object/classes/class.ilObjectActivation.php";
49 $this->lng->loadLanguageModule(
'rep');
52 $section->setTitle($this->lng->txt(
'rep_activation_availability'));
56 $act_obj_info = $act_ref_info =
"";
59 $act_obj_info =
' '.$this->lng->txt(
'rep_activation_online_object_info');
60 $act_ref_info = $this->lng->txt(
'rep_activation_access_ref_info');
64 $online->setInfo($this->lng->txt(
'poll_activation_online_info').$act_obj_info);
67 $act_type =
new ilCheckboxInputGUI($this->lng->txt(
'rep_visibility_until'),
'access_type');
70 $this->tpl->addJavaScript(
'./Services/Form/js/date_duration.js');
71 include_once
"Services/Form/classes/class.ilDateDurationInputGUI.php";
73 $dur->setShowTime(
true);
74 $date = $this->
object->getAccessBegin();
76 $dur->setStartText($this->lng->txt(
'rep_activation_limited_start'));
77 $date = $this->
object->getAccessEnd();
79 $dur->setEndText($this->lng->txt(
'rep_activation_limited_end'));
80 $act_type->addSubItem($dur);
88 $section->setTitle($this->lng->txt(
'poll_voting_period_and_results'));
94 $vdur->setShowTime(
true);
95 $date = $this->
object->getVotingPeriodBegin();
97 $vdur->setStartText($this->lng->txt(
'poll_voting_period_start'));
98 $date = $this->
object->getVotingPeriodEnd();
100 $vdur->setEndText($this->lng->txt(
'poll_voting_period_end'));
101 $prd->addSubItem($vdur);
118 $show_result_as->setRequired(
true);
121 $show_result_as->addOption($result_bar);
124 $a_form->
addItem($show_result_as);
127 $sort->setRequired(
true);
128 $sort->addOption(
new ilRadioOption(
$lng->txt(
"poll_result_sorting_answers"), 0));
133 $section->setTitle($this->lng->txt(
'poll_comments'));
143 include_once
"Services/Object/classes/class.ilObjectActivation.php";
145 $a_values[
"online"] = $this->
object->IsOnline();
146 $a_values[
"results"] = $this->
object->getViewResults();
148 $a_values[
"period"] = $this->
object->getVotingPeriod();
149 $a_values[
"sort"] = $this->
object->getSortResultByVotes();
150 $a_values[
"comment"] = $this->
object->getShowComments();
151 $a_values[
"show_results_as"] = $this->
object->getShowResultsAs();
161 $a_form->
getItemByPostVar(
"results")->setAlert($this->lng->txt(
"poll_view_results_after_period_impossible"));
164 return parent::validateCustom($a_form);
169 $this->
object->setViewResults($a_form->
getInput(
"results"));
170 $this->
object->setOnline($a_form->
getInput(
"online"));
171 $this->
object->setSortResultByVotes($a_form->
getInput(
"sort"));
172 $this->
object->setShowComments($a_form->
getInput(
"comment"));
173 $this->
object->setShowResultsAs($a_form->
getInput(
"show_results_as"));
175 include_once
"Services/Object/classes/class.ilObjectActivation.php";
176 if($a_form->
getInput(
"access_type"))
181 $this->
object->setAccessBegin($period->getStart()->get(
IL_CAL_UNIX));
182 $this->
object->setAccessEnd($period->getEnd()->get(
IL_CAL_UNIX));
191 $this->
object->setVotingPeriod(1);
194 $this->
object->setVotingPeriodBegin($period->getStart()->get(
IL_CAL_UNIX));
195 $this->
object->setVotingPeriodEnd($period->getEnd()->get(
IL_CAL_UNIX));
199 $this->
object->setVotingPeriod(0);
205 global
$lng, $ilHelp;
207 $ilHelp->setScreenIdComponent(
"poll");
211 $this->tabs_gui->addTab(
"content",
212 $lng->txt(
"content"),
213 $this->ctrl->getLinkTarget($this,
""));
218 $this->tabs_gui->addTab(
"settings",
219 $lng->txt(
"settings"),
220 $this->ctrl->getLinkTarget($this,
"edit"));
222 $this->tabs_gui->addTab(
"participants",
223 $lng->txt(
"poll_result"),
224 $this->ctrl->getLinkTarget($this,
"showParticipants"));
226 $this->tabs_gui->addTab(
"export",
228 $this->ctrl->getLinkTargetByClass(
"ilexportgui",
""));
237 global
$ilCtrl,
$tpl, $ilTabs, $ilNavigationHistory;
239 $next_class =
$ilCtrl->getNextClass($this);
242 $tpl->getStandardTemplate();
248 $link =
$ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"frameset");
249 $ilNavigationHistory->addItem($this->node_id, $link,
"poll");
254 case "ilinfoscreengui":
256 $this->infoScreenForward();
259 case "ilcommonactiondispatchergui":
260 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
262 $this->ctrl->forwardCommand($gui);
265 case "ilpermissiongui":
267 $ilTabs->activateTab(
"id_permissions");
268 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
270 $this->ctrl->forwardCommand($perm_gui);
273 case "ilobjectcopygui":
274 include_once
"./Services/Object/classes/class.ilObjectCopyGUI.php";
276 $cp->setType(
"poll");
277 $this->ctrl->forwardCommand($cp);
282 $ilTabs->activateTab(
"export");
283 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
285 $exp_gui->addFormat(
"xml");
286 $ilCtrl->forwardCommand($exp_gui);
290 return parent::executeCommand();
313 $ilTabs->activateTab(
"content");
317 if($this->object->countVotes())
319 $url =
$ilCtrl->getLinkTarget($this,
"showParticipants");
321 " <a href=\"".$url.
"\">»".
$lng->txt(
"poll_result").
"</a>");
327 $tpl->setPermanentLink(
'poll', $this->node_id);
329 $tpl->setContent($a_form->getHTML());
336 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
338 $form->setFormAction(
$ilCtrl->getFormAction($this,
"saveQuestion"));
339 $form->setTitle(
$lng->txt(
"obj_poll"));
342 $question->setRequired(
true);
343 $question->setCols(40);
344 $question->setRows(2);
345 $question->setValue($this->object->getQuestion());
346 $question->setDisabled($a_read_only);
347 $form->addItem($question);
349 $dimensions =
" (".ilObjPoll::getImageSize().
"px)";
351 $img->setDisabled($a_read_only);
352 $form->addItem(
$img);
355 $file = $this->
object->getImageFullPath(
true);
362 $anonymous->setRequired(
true);
364 $option->setInfo(
$lng->txt(
"poll_mode_anonymous_info"));
365 $anonymous->addOption($option);
367 $option->setInfo(
$lng->txt(
"poll_mode_personal_info"));
368 $anonymous->addOption($option);
369 $anonymous->setValue($this->object->getNonAnonymous());
370 $anonymous->setDisabled($a_read_only);
371 $form->addItem($anonymous);
374 $nanswers->setRequired(
true);
375 $nanswers->setMinValue(1);
376 $nanswers->setSize(3);
377 $nanswers->setValue($this->object->getMaxNumberOfAnswers());
378 $nanswers->setDisabled($a_read_only);
379 $form->addItem($nanswers);
382 $answers->setRequired(
true);
383 $answers->setMulti(
true,
true);
384 $answers->setDisabled($a_read_only);
385 $form->addItem($answers);
387 $multi_answers = array();
388 foreach($this->object->getAnswers() as $idx => $item)
392 $answers->setValue($item[
"answer"]);
394 $multi_answers[] = $item[
"answer"];
396 $answers->setMultiValues($multi_answers);
400 $form->addCommandButton(
"saveQuestion",
$lng->txt(
"save"));
409 if($form->checkInput())
411 $this->
object->setQuestion($form->getInput(
"question"));
412 $this->
object->setNonAnonymous($form->getInput(
"mode"));
414 $image = $form->getItemByPostVar(
"image");
415 if($_FILES[
"image"][
"tmp_name"])
417 $this->
object->uploadImage($_FILES[
"image"]);
419 else if($image->getDeletionFlag())
421 $this->
object->deleteImage();
424 $nr_of_anwers = $this->
object->saveAnswers($form->getInput(
"answers"));
427 $this->
object->setMaxNumberOfAnswers(min($form->getInput(
"nanswers"), $nr_of_anwers));
429 if($this->object->update())
432 $this->ctrl->redirect($this,
"render");
436 $form->setValuesByPost();
444 if(!$this->object->getNonAnonymous())
449 $ilTabs->addSubTab(
"result_answers",
$lng->txt(
"poll_result_answers"),
450 $ilCtrl->getLinkTarget($this,
"showParticipants"));
451 $ilTabs->addSubTab(
"result_users",
$lng->txt(
"poll_result_users"),
452 $ilCtrl->getLinkTarget($this,
"showParticipantVotes"));
454 $ilTabs->activateSubTab($a_active);
467 $ilTabs->activateTab(
"participants");
470 include_once
"Modules/Poll/classes/class.ilPollAnswerTableGUI.php";
480 !$this->object->getNonAnonymous())
486 $ilTabs->activateTab(
"participants");
489 include_once
"Modules/Poll/classes/class.ilPollUserTableGUI.php";
504 $ilTabs->activateTab(
"participants");
506 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
508 $cgui->setHeaderText(
$lng->txt(
"poll_delete_votes_sure"));
510 $cgui->setFormAction($this->ctrl->getFormAction($this));
511 $cgui->setCancel(
$lng->txt(
"cancel"),
"showParticipants");
512 $cgui->setConfirm(
$lng->txt(
"confirm"),
"deleteAllVotes");
514 $tpl->setContent($cgui->getHTML());
527 $this->
object->deleteAllVotes();
529 $ilCtrl->redirect($this,
"showParticipants");
537 if($this->object->getMaxNumberOfAnswers() > 1)
539 if(
sizeof(
$_POST[
"aw"]) > $this->object->getMaxNumberOfAnswers())
558 unset(
$_SESSION[
"last_poll_vote"][$this->object->getId()]);
559 $this->
object->saveVote($ilUser->getId(),
$_POST[
"aw"]);
568 include_once
"Services/Link/classes/class.ilLink.php";
576 include_once
"./Services/Notification/classes/class.ilNotification.php";
580 include_once
"Services/Link/classes/class.ilLink.php";
588 include_once
"./Services/Notification/classes/class.ilNotification.php";
592 include_once
"Services/Link/classes/class.ilLink.php";
601 include_once
"./Services/Notification/classes/class.ilNotification.php";
603 $this->object->getId(),
null,
true);
609 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
611 $ntf->setLangModules(array(
"poll"));
612 $ntf->setRefId($this->ref_id);
614 if($this->object->getNonAnonymous())
616 $ntf->setChangedByUserId(
$ilUser->getId());
619 $ntf->setSubjectLangId(
'poll_vote_notification_subject');
620 $ntf->setIntroductionLangId(
'poll_vote_notification_body');
621 $ntf->setGotoLangId(
'poll_vote_notification_link');
622 $ntf->setReasonLangId(
'poll_vote_notification_reason');
624 $notified = $ntf->sendMail($users,
null,
"read");
643 if (is_object($this->
object))
645 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"", $this->node_id);
654 public static function _goto($a_target)
656 global
$tree, $ilAccess;
658 $id = explode(
"_", $a_target);
662 if ($ilAccess->checkAccess(
"write",
"",
$ref_id))
664 $_GET[
"baseClass"] =
"ilRepositoryGUI";
666 $_GET[
"cmd"] =
"showParticipants";
667 include(
"ilias.php");
676 include_once
"Services/Link/classes/class.ilLink.php";
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
@classDescription Date and time handling
Export User Interface Class.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
static updateNotificationTime($type, $id, array $user_ids, $page_id=false)
Update the last mail timestamp for given object and users.
getHTML()
return user view
render($a_form=null)
Render object context.
static _goto($a_target)
Deep link.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
executeCommand()
execute command
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
validateCustom(ilPropertyFormGUI $a_form)
Validate custom values (if not possible with checkInput())
setTabs()
create tabs (repository/workspace switch)
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getType()
Functions that must be overwritten.
addLocatorItems()
Functions to be overwritten.
initQuestionForm($a_read_only=false)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
setParticipantsSubTabs($a_active)
const VIEW_RESULTS_ALWAYS
const SHOW_RESULTS_AS_PIECHART
const VIEW_RESULTS_AFTER_VOTE
const SHOW_RESULTS_AS_BARCHART
const VIEW_RESULTS_AFTER_PERIOD
New implementation of ilObjectGUI.
getAccessHandler()
Get access handler.
prepareOutput()
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
getCreationMode()
get creation mode
const TIMINGS_DEACTIVATED
GUI class for the workflow of copying objects.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
TableGUI class for poll answers.
TableGUI class for poll users.
This class represents an option in a radio group.
Wrapper classes for system notifications.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.