Skip to content
Snippets Groups Projects
Commit b599d9b4 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

work in progress, re #2341

parent 9b088733
No related branches found
No related tags found
No related merge requests found
Pipeline #10410 passed
......@@ -4,6 +4,39 @@ use \Studip\Activity\ActivityProvider;
class ActivityfeedController extends AuthenticatedController
{
public function configuration_action()
{
$this->config = WidgetHelper::getWidgetUserConfig($GLOBALS['user']->id, 'ACTIVITY_FEED');
$this->modules = $this->getAllModules();
$this->context_translations = [
Context::COURSE => _('Veranstaltungen'),
Context::INSTITUTE => _('Einrichtungen'),
Context::USER => _('Persönlich'),
'system' => _('Global')
];
PageLayout::setTitle(_('Aktivitäten konfigurieren'));
$form = Studip\Forms\Form::create();
foreach ($this->modules as $context => $provider) {
$fieldset = new Studip\Forms\Fieldset($this->context_translations[$context]);
$checkboxes = new Studip\Forms\MulticheckboxInput(
"provider[{$context}]",
'foo',
$this->config[$context] ?? [],
['options' => $provider]
);
$fieldset->addInput($checkboxes);
$form->addPart($fieldset);
}
$this->form = $form;
}
public function save_action()
{
if (Config::get()->ACTIVITY_FEED === NULL) {
......@@ -78,18 +111,4 @@ class ActivityfeedController extends AuthenticatedController
return $modules;
}
public function configuration_action()
{
$this->config = WidgetHelper::getWidgetUserConfig($GLOBALS['user']->id, 'ACTIVITY_FEED');
$this->modules = $this->getAllModules();
$this->context_translations = [
Context::COURSE => _('Veranstaltungen'),
Context::INSTITUTE => _('Einrichtungen'),
Context::USER => _('Persönlich'),
'system' => _('Global')
];
PageLayout::setTitle(_('Aktivitäten konfigurieren'));
}
}
......@@ -3,28 +3,29 @@
* @var ActivityfeedController $controller
* @var array $modules
* @var array $context_translations
* @var \Studip\Forms\Form $form
*/
?>
<div id="activityEdit">
<form id="configure_activity" action="<?= $controller->link_for('activityfeed/save') ?>" method="post" class="default" data-dialog>
<h1><?= _("Anzuzeigende Bereiche:") ?></h1>
<?= $form->render() ?>
<? foreach ($modules as $context => $provider): ?>
<fieldset>
<legend><?= htmlReady($context_translations[$context]) ?></legend>
<? foreach ($provider as $prv_id => $prv_name) : ?>
<label>
<input type="checkbox" name="provider[<?= $context ?>][]" value="<?= htmlReady($prv_id) ?>"
<?= empty($config) || (is_array($config[$context]) && in_array($prv_id, $config[$context])) ? 'checked' : ''?>>
<?= htmlReady($prv_name) ?>
</label>
<? endforeach ?>
</fieldset>
<? endforeach; ?>
<form action="<?= $controller->link_for('activityfeed/save') ?>" method="post" class="default" data-dialog>
<h1><?= _("Anzuzeigende Bereiche:") ?></h1>
<footer data-dialog-button>
<?= Studip\Button::createAccept(_('Speichern')) ?>
<?= Studip\Button::createCancel(_('Abbrechen'), URLHelper::getLink('dispatch.php/start')) ?>
</footer>
</form>
</div>
<? foreach ($modules as $context => $provider): ?>
<fieldset>
<legend><?= htmlReady($context_translations[$context]) ?></legend>
<? foreach ($provider as $prv_id => $prv_name) : ?>
<label>
<input type="checkbox" name="provider[<?= $context ?>][]" value="<?= htmlReady($prv_id) ?>"
<?= empty($config) || (is_array($config[$context]) && in_array($prv_id, $config[$context])) ? 'checked' : ''?>>
<?= htmlReady($prv_name) ?>
</label>
<? endforeach ?>
</fieldset>
<? endforeach; ?>
<footer data-dialog-button>
<?= Studip\Button::createAccept(_('Speichern')) ?>
<?= Studip\Button::createCancel(_('Abbrechen'), URLHelper::getLink('dispatch.php/start')) ?>
</footer>
</form>
<?php
namespace Studip\Forms;
class MulticheckboxInput extends Input
{
public function render()
{
$options = $this->extractOptionsFromAttributes($this->attributes);
$name = $this->name;
if (substr($name, -2) === '[]') {
$name .= substr($name, 0, -2);
}
$template = $GLOBALS['template_factory']->open('forms/multiselect_input');
$template->title = $this->title;
$template->name = $name;
$template->value = $this->value;
$template->id = md5(uniqid());
$template->required = $this->required;
$template->attributes = arrayToHtmlAttributes($this->attributes);
$template->options = $options;
return $template->render();
}
public function getRequestValue()
{
return \Request::getArray($this->name);
}
}
<input type="hidden" name="<?= htmlReady($name) ?>" value="0">
<label<?= ($required ? ' class="studiprequired"' : '') ?>>
<label<?= ($required ? ' class="studiprequired"' : '') ?>>
<input type="checkbox"
v-model="<?= htmlReady($this->name) ?>"
name="<?= htmlReady($this->name) ?>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment