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 include_once
"Services/Form/classes/class.ilDateDurationInputGUI.php";
69 $dur->setShowTime(
true);
76 $section->setTitle($this->lng->txt(
'poll_voting_period_and_results'));
80 $vdur->setShowTime(
true);
96 $show_result_as->setRequired(
true);
99 $show_result_as->addOption($result_bar);
102 $a_form->
addItem($show_result_as);
105 $sort->setRequired(
true);
106 $sort->addOption(
new ilRadioOption(
$lng->txt(
"poll_result_sorting_answers"), 0));
111 $section->setTitle($this->lng->txt(
'poll_comments'));
121 include_once
"Services/Object/classes/class.ilObjectActivation.php";
123 $a_values[
"online"] = $this->
object->IsOnline();
124 $a_values[
"results"] = $this->
object->getViewResults();
125 $a_values[
"access_period"][
"start"] = $this->
object->getAccessBegin()
128 $a_values[
"access_period"][
"end"] = $this->
object->getAccessEnd()
131 $a_values[
"voting_period"][
"start"] = $this->
object->getVotingPeriodBegin()
134 $a_values[
"voting_period"][
"end"] = $this->
object->getVotingPeriodEnd()
137 $a_values[
"sort"] = $this->
object->getSortResultByVotes();
138 $a_values[
"comment"] = $this->
object->getShowComments();
139 $a_values[
"show_results_as"] = $this->
object->getShowResultsAs();
145 if(!$a_form->
getInput(
"voting_period") &&
149 $a_form->
getItemByPostVar(
"results")->setAlert($this->lng->txt(
"poll_view_results_after_period_impossible"));
152 return parent::validateCustom($a_form);
157 $this->
object->setViewResults($a_form->
getInput(
"results"));
158 $this->
object->setOnline($a_form->
getInput(
"online"));
159 $this->
object->setSortResultByVotes($a_form->
getInput(
"sort"));
160 $this->
object->setShowComments($a_form->
getInput(
"comment"));
161 $this->
object->setShowResultsAs($a_form->
getInput(
"show_results_as"));
163 include_once
"Services/Object/classes/class.ilObjectActivation.php";
165 if($period->getStart() && $period->getEnd())
168 $this->
object->setAccessBegin($period->getStart()->get(
IL_CAL_UNIX));
169 $this->
object->setAccessEnd($period->getEnd()->get(
IL_CAL_UNIX));
177 if($period->getStart() && $period->getEnd())
179 $this->
object->setVotingPeriod(1);
180 $this->
object->setVotingPeriodBegin($period->getStart()->get(
IL_CAL_UNIX));
181 $this->
object->setVotingPeriodEnd($period->getEnd()->get(
IL_CAL_UNIX));
186 $this->
object->setVotingPeriodBegin(
null);
187 $this->
object->setVotingPeriodEnd(
null);
188 $this->
object->setVotingPeriod(0);
194 global
$lng, $ilHelp;
196 $ilHelp->setScreenIdComponent(
"poll");
200 $this->tabs_gui->addTab(
"content",
201 $lng->txt(
"content"),
202 $this->ctrl->getLinkTarget($this,
""));
207 $this->tabs_gui->addTab(
"settings",
208 $lng->txt(
"settings"),
209 $this->ctrl->getLinkTarget($this,
"edit"));
211 $this->tabs_gui->addTab(
"participants",
212 $lng->txt(
"poll_result"),
213 $this->ctrl->getLinkTarget($this,
"showParticipants"));
215 $this->tabs_gui->addTab(
"export",
217 $this->ctrl->getLinkTargetByClass(
"ilexportgui",
""));
226 global
$ilCtrl,
$tpl, $ilTabs, $ilNavigationHistory;
228 $next_class =
$ilCtrl->getNextClass($this);
231 $tpl->getStandardTemplate();
237 $link =
$ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"frameset");
238 $ilNavigationHistory->addItem($this->node_id, $link,
"poll");
243 case "ilinfoscreengui":
245 $this->infoScreenForward();
248 case "ilcommonactiondispatchergui":
249 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
251 $this->ctrl->forwardCommand($gui);
254 case "ilpermissiongui":
256 $ilTabs->activateTab(
"id_permissions");
257 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
259 $this->ctrl->forwardCommand($perm_gui);
262 case "ilobjectcopygui":
263 include_once
"./Services/Object/classes/class.ilObjectCopyGUI.php";
265 $cp->setType(
"poll");
266 $this->ctrl->forwardCommand($cp);
271 $ilTabs->activateTab(
"export");
272 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
274 $exp_gui->addFormat(
"xml");
275 $ilCtrl->forwardCommand($exp_gui);
279 return parent::executeCommand();
302 $ilTabs->activateTab(
"content");
306 if($this->object->countVotes())
308 $url =
$ilCtrl->getLinkTarget($this,
"showParticipants");
310 " <a href=\"".$url.
"\">»".
$lng->txt(
"poll_result").
"</a>");
316 $tpl->setPermanentLink(
'poll', $this->node_id);
318 $tpl->setContent($a_form->getHTML());
325 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
327 $form->setFormAction(
$ilCtrl->getFormAction($this,
"saveQuestion"));
328 $form->setTitle(
$lng->txt(
"obj_poll"));
331 $question->setRequired(
true);
332 $question->setCols(40);
333 $question->setRows(2);
334 $question->setValue($this->object->getQuestion());
335 $question->setDisabled($a_read_only);
336 $form->addItem($question);
338 $dimensions =
" (".ilObjPoll::getImageSize().
"px)";
340 $img->setDisabled($a_read_only);
341 $form->addItem(
$img);
344 $file = $this->
object->getImageFullPath(
true);
351 $anonymous->setRequired(
true);
353 $option->setInfo(
$lng->txt(
"poll_mode_anonymous_info"));
354 $anonymous->addOption($option);
356 $option->setInfo(
$lng->txt(
"poll_mode_personal_info"));
357 $anonymous->addOption($option);
358 $anonymous->setValue($this->object->getNonAnonymous());
359 $anonymous->setDisabled($a_read_only);
360 $form->addItem($anonymous);
363 $nanswers->setRequired(
true);
364 $nanswers->setMinValue(1);
365 $nanswers->setSize(3);
366 $nanswers->setValue($this->object->getMaxNumberOfAnswers());
367 $nanswers->setDisabled($a_read_only);
368 $form->addItem($nanswers);
371 $answers->setRequired(
true);
372 $answers->setMulti(
true,
true);
373 $answers->setDisabled($a_read_only);
374 $form->addItem($answers);
376 $multi_answers = array();
377 foreach($this->object->getAnswers() as $idx => $item)
381 $answers->setValue($item[
"answer"]);
383 $multi_answers[] = $item[
"answer"];
385 $answers->setMultiValues($multi_answers);
389 $form->addCommandButton(
"saveQuestion",
$lng->txt(
"save"));
398 if($form->checkInput())
400 $this->
object->setQuestion($form->getInput(
"question"));
401 $this->
object->setNonAnonymous($form->getInput(
"mode"));
403 $image = $form->getItemByPostVar(
"image");
404 if($_FILES[
"image"][
"tmp_name"])
406 $this->
object->uploadImage($_FILES[
"image"]);
408 else if($image->getDeletionFlag())
410 $this->
object->deleteImage();
413 $nr_of_anwers = $this->
object->saveAnswers($form->getInput(
"answers"));
416 $this->
object->setMaxNumberOfAnswers(min($form->getInput(
"nanswers"), $nr_of_anwers));
418 if($this->object->update())
421 $this->ctrl->redirect($this,
"render");
425 $form->setValuesByPost();
433 if(!$this->object->getNonAnonymous())
438 $ilTabs->addSubTab(
"result_answers",
$lng->txt(
"poll_result_answers"),
439 $ilCtrl->getLinkTarget($this,
"showParticipants"));
440 $ilTabs->addSubTab(
"result_users",
$lng->txt(
"poll_result_users"),
441 $ilCtrl->getLinkTarget($this,
"showParticipantVotes"));
443 $ilTabs->activateSubTab($a_active);
456 $ilTabs->activateTab(
"participants");
459 include_once
"Modules/Poll/classes/class.ilPollAnswerTableGUI.php";
469 !$this->object->getNonAnonymous())
475 $ilTabs->activateTab(
"participants");
478 include_once
"Modules/Poll/classes/class.ilPollUserTableGUI.php";
493 $ilTabs->activateTab(
"participants");
495 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
497 $cgui->setHeaderText(
$lng->txt(
"poll_delete_votes_sure"));
499 $cgui->setFormAction($this->ctrl->getFormAction($this));
500 $cgui->setCancel(
$lng->txt(
"cancel"),
"showParticipants");
501 $cgui->setConfirm(
$lng->txt(
"confirm"),
"deleteAllVotes");
503 $tpl->setContent($cgui->getHTML());
516 $this->
object->deleteAllVotes();
518 $ilCtrl->redirect($this,
"showParticipants");
526 if($this->object->getMaxNumberOfAnswers() > 1)
528 if(
sizeof(
$_POST[
"aw"]) > $this->object->getMaxNumberOfAnswers())
547 unset(
$_SESSION[
"last_poll_vote"][$this->object->getId()]);
548 $this->
object->saveVote($ilUser->getId(),
$_POST[
"aw"]);
557 include_once
"Services/Link/classes/class.ilLink.php";
565 include_once
"./Services/Notification/classes/class.ilNotification.php";
569 include_once
"Services/Link/classes/class.ilLink.php";
577 include_once
"./Services/Notification/classes/class.ilNotification.php";
581 include_once
"Services/Link/classes/class.ilLink.php";
590 include_once
"./Services/Notification/classes/class.ilNotification.php";
592 $this->object->getId(),
null,
true);
598 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
600 $ntf->setLangModules(array(
"poll"));
601 $ntf->setRefId($this->ref_id);
603 if($this->object->getNonAnonymous())
605 $ntf->setChangedByUserId(
$ilUser->getId());
608 $ntf->setSubjectLangId(
'poll_vote_notification_subject');
609 $ntf->setIntroductionLangId(
'poll_vote_notification_body');
610 $ntf->setGotoLangId(
'poll_vote_notification_link');
611 $ntf->setReasonLangId(
'poll_vote_notification_reason');
613 $notified = $ntf->sendMail($users,
null,
"read");
632 if (is_object($this->
object))
634 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"", $this->node_id);
643 public static function _goto($a_target)
645 global
$tree, $ilAccess;
647 $id = explode(
"_", $a_target);
651 if ($ilAccess->checkAccess(
"write",
"",
$ref_id))
653 $_GET[
"baseClass"] =
"ilRepositoryGUI";
655 $_GET[
"cmd"] =
"showParticipants";
656 include(
"ilias.php");
665 include_once
"Services/Link/classes/class.ilLink.php";
An exception for terminatinating execution or to throw for unit testing.
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($a_show_subobjects=true)
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.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file