Skip to content

Commit

Permalink
Merge pull request #5 from iljalukin/ilias8
Browse files Browse the repository at this point in the history
Revert bbbadc7 and add setOnScreenMessage with keep-parameter
  • Loading branch information
Saaweel authored Oct 11, 2024
2 parents fe837f2 + f1025ce commit b2f1901
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 44 deletions.
2 changes: 1 addition & 1 deletion classes/Conf/class.xlvoConfGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function update()
$xlvoConfFormGUI = new xlvoConfFormGUI($this);
$xlvoConfFormGUI->setValuesByPost();
if ($xlvoConfFormGUI->saveObject()) {
ilLiveVotingPlugin::sendSuccess($this->txt('msg_success'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', $this->txt('msg_success'), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
self::dic()->ui()->mainTemplate()->setContent($xlvoConfFormGUI->getHTML());
Expand Down
7 changes: 1 addition & 6 deletions classes/Results/class.xlvoResultsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ private function showResults()
$this->buildFilters($table);
$table->initFilter();
$table->buildData($this->obj_id, $this->round->getId());
if (isset($_SESSION['onscreen_message'])) {
$message = $_SESSION['onscreen_message'];
self::dic()->ui()->mainTemplate()->setOnScreenMessage($message['type'], $message['msg']);
unset($_SESSION['onscreen_message']); // Limpiar el mensaje después de mostrarlo
}
self::dic()->ui()->mainTemplate()->setContent($table->getHTML());
}

Expand Down Expand Up @@ -159,7 +154,7 @@ private function newRound()
$newRound->setObjId($this->obj_id);
$newRound->store();
self::dic()->ctrl()->setParameter($this, 'round_id', xlvoRound::getLatestRound($this->obj_id)->getId());
$_SESSION['onscreen_message'] = array('type' => 'success', 'msg' => self::plugin()->translate("common_new_round_created"));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("common_new_round_created"), true);
self::dic()->ctrl()->redirect($this, self::CMD_SHOW);
}

Expand Down
2 changes: 1 addition & 1 deletion classes/Voter/class.xlvoVoter2GUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function checkPin()
self::dic()->ctrl()->redirect($this, self::CMD_START_VOTER_PLAYER);
} catch (xlvoVoterException $e) {
$param_manager->setPin('');
ilLiveVotingPlugin::sendFailure($this->txt('msg_validation_error_pin_' . $e->getCode()));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', $this->txt('msg_validation_error_pin_' . $e->getCode()), true);
$this->index();
}
}
Expand Down
55 changes: 25 additions & 30 deletions classes/Voting/class.xlvoVotingGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function executeCommand()
protected function content()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
} elseif (ilObjLiveVotingAccess::hasWriteAccess()) {
$b = ilLinkButton::getInstance();
$b->setPrimary(true);
Expand Down Expand Up @@ -174,11 +174,6 @@ protected function content()
. "_info_manual_" . $step)) . '</li>';
}, range(1, 4))) . '</ol>' : ''); // TODO: default.css not loaded

if (isset($_SESSION['onscreen_message'])) {
$message = $_SESSION['onscreen_message'];
self::dic()->ui()->mainTemplate()->setOnScreenMessage($message['type'], $message['msg']);
unset($_SESSION['onscreen_message']); // Limpiar el mensaje después de mostrarlo
}
self::dic()->ui()->mainTemplate()->setContent($xlvoVotingTableGUI->getHTML() . $powerpoint_export);
}
}
Expand All @@ -190,7 +185,7 @@ protected function content()
protected function selectType(bool $error = false)
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
$form = new ilPropertyFormGUI();
Expand Down Expand Up @@ -225,7 +220,7 @@ protected function showTypeError(){
protected function add()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
$xlvoVoting = new xlvoVoting();
Expand All @@ -243,16 +238,16 @@ protected function add()
protected function create()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
$xlvoVoting = new xlvoVoting();
$xlvoVoting->setVotingType($_POST[self::F_TYPE]);
$xlvoVotingFormGUI = xlvoVotingFormGUI::get($this, $xlvoVoting);
$xlvoVotingFormGUI->setValuesByPost();
if ($xlvoVotingFormGUI->saveObject()) {
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("msg_success_voting_created"));

self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("msg_success_voting_created"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
self::dic()->ui()->mainTemplate()->setContent($xlvoVotingFormGUI->getHTML());
}
Expand All @@ -265,7 +260,7 @@ protected function create()
protected function edit()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
/**
Expand Down Expand Up @@ -352,16 +347,16 @@ public function updateAndStay()
protected function update($cmd = self::CMD_STANDARD)
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
$xlvoVoting = xlvoVoting::find($_GET[self::IDENTIFIER]);
self::dic()->ctrl()->setParameter($this, self::IDENTIFIER, $xlvoVoting->getId());
$xlvoVotingFormGUI = xlvoVotingFormGUI::get($this, $xlvoVoting);
$xlvoVotingFormGUI->setValuesByPost();
if ($xlvoVotingFormGUI->saveObject()) {
//ilLiveVotingPlugin::sendSuccess(self::plugin()->translate('msg_success_voting_updated'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("msg_success_voting_updated"));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("msg_success_voting_updated"), true);
self::dic()->ctrl()->redirect($this, $cmd);
}
self::dic()->ui()->mainTemplate()->setContent($xlvoVotingFormGUI->getHTML());
}
Expand All @@ -374,7 +369,7 @@ protected function update($cmd = self::CMD_STANDARD)
protected function confirmDelete()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {

Expand All @@ -393,7 +388,7 @@ protected function confirmDelete()

self::dic()->ui()->mainTemplate()->setContent($confirm->getHTML());
} else {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_object'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_object"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
}
Expand All @@ -406,7 +401,7 @@ protected function confirmDelete()
protected function delete()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {

Expand All @@ -433,7 +428,7 @@ protected function delete()
$xlvoVoting->delete();
$this->cancel();
} else {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('delete_failed'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("delete_failed"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
}
Expand All @@ -446,7 +441,7 @@ protected function delete()
protected function confirmReset()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {

Expand All @@ -456,7 +451,7 @@ protected function confirmReset()
$xlvoVoting = xlvoVoting::find($_GET[self::IDENTIFIER]);
if ($xlvoVoting->getObjId() == $this->getObjId()) {

ilLiveVotingPlugin::sendQuestion($this->txt('confirm_reset'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('question', $this->txt('confirm_reset'), true);

$confirm = new ilConfirmationGUI();
$confirm->addItem(self::IDENTIFIER, $xlvoVoting->getId(), $xlvoVoting->getTitle());
Expand All @@ -468,7 +463,7 @@ protected function confirmReset()
self::dic()->ui()->mainTemplate()->setContent($confirm->getHTML());

} else {
ilLiveVotingPlugin::sendFailure($this->txt('permission_denied_object'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', $this->txt('permission_denied_object'), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
}
Expand All @@ -481,7 +476,7 @@ protected function confirmReset()
protected function reset()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
/**
Expand All @@ -500,7 +495,7 @@ protected function reset()
}
$this->cancel();
} else {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('reset_failed'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("reset_failed"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
}
Expand All @@ -513,7 +508,7 @@ protected function reset()
protected function confirmResetAll()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
//ilLiveVotingPlugin::sendQuestion($this->txt('confirm_reset_all'), true);
Expand Down Expand Up @@ -543,7 +538,7 @@ protected function confirmResetAll()
protected function resetAll()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
/**
Expand Down Expand Up @@ -575,7 +570,7 @@ protected function duplicate()
*/
$xlvoVoting = xlvoVoting::find($_GET[self::IDENTIFIER]);
$xlvoVoting->fullClone(true, true);
$_SESSION['onscreen_message'] = array('type' => 'success', 'msg' => self::plugin()->translate('voting_msg_duplicated'));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("voting_msg_duplicated"), true);
$this->cancel();
}

Expand Down Expand Up @@ -635,7 +630,7 @@ protected function duplicateToAnotherObject()
*/
$xlvoVoting = xlvoVoting::find($_GET[self::IDENTIFIER]);
$xlvoVoting->fullClone(true, true, $obj_id);
ilLiveVotingPlugin::sendSuccess(self::plugin()->translate('voting_msg_duplicated'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("voting_msg_duplicated"), true);
$this->cancel();
}

Expand All @@ -655,7 +650,7 @@ protected function cancel()
protected function saveSorting()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("permission_denied_write"), true);
} else {
if (is_array($_POST['position'])) {
foreach ($_POST['position'] as $k => $v) {
Expand All @@ -667,7 +662,7 @@ protected function saveSorting()
$xlvoVoting->store();
}
}
$_SESSION['onscreen_message'] = array('type' => 'success', 'msg' => self::plugin()->translate('voting_msg_sorting_saved'));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("voting_msg_sorting_saved"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
}
}
Expand Down
12 changes: 6 additions & 6 deletions classes/class.ilObjLiveVotingGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function showContentAfterCreation()
public function editProperties()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('obj_permission_denied'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("obj_permission_denied"), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
} else {
self::dic()->tabs()->activateTab(self::TAB_EDIT);
Expand Down Expand Up @@ -369,7 +369,7 @@ protected function initPropertiesForm()
{

if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('obj_permission_denied'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("obj_permission_denied"), true);
} else {
$this->form = new ilPropertyFormGUI();
$this->form->setTitle(self::plugin()->translate('obj_edit_properties'));
Expand Down Expand Up @@ -466,7 +466,7 @@ protected function fillPropertiesForm()
public function updateProperties()
{
if (!ilObjLiveVotingAccess::hasWriteAccess()) {
ilLiveVotingPlugin::sendFailure(self::plugin()->translate('obj_permission_denied_write'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('failure', self::plugin()->translate("obj_permission_denied"), true);
} else {
self::dic()->tabs()->activateTab(self::TAB_EDIT);
$this->initPropertiesForm();
Expand Down Expand Up @@ -499,7 +499,7 @@ public function updateProperties()
$config->setShowAttendees($this->form->getInput(xlvoVotingConfig::F_SHOW_ATTENDEES));

$config->store();
ilLiveVotingPlugin::sendSuccess(self::plugin()->translate('obj_msg_properties_form_saved'), true);
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::plugin()->translate("obj_msg_properties_form_saved"), true);
self::dic()->ctrl()->redirect($this, self::CMD_EDIT);
}

Expand Down Expand Up @@ -582,7 +582,7 @@ protected function redirectToPublicVotingMask()
public function addToDeskObject(): void
{
ilDesktopItemGUI::addToDesktop();
ilLiveVotingPlugin::sendSuccess(self::dic()->language()->txt("added_to_desktop"));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::dic()->language()->txt("added_to_desktop"), true);
}


Expand All @@ -592,6 +592,6 @@ public function addToDeskObject(): void
public function removeFromDeskObject(): void
{
ilDesktopItemGUI::removeFromDesktop();
ilLiveVotingPlugin::sendSuccess(self::dic()->language()->txt("removed_from_desktop"));
self::dic()->ui()->mainTemplate()->setOnScreenMessage('success', self::dic()->language()->txt("removed_from_desktop"), true);
}
}

0 comments on commit b2f1901

Please sign in to comment.