Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix if styleSheetId cannot be retrieved #8

Open
wants to merge 8 commits into
base: r9_develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion classes/Content/PageEditor/class.xudfPageObjectGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ public function __construct(xudfContentGUI $parent_gui)
$tpl->parseCurrentBlock();

$tpl->setCurrentBlock("ContentStyle");
$style_id = $parent_gui->getObject()->getStyleSheetId();
if ($style_id == null) {
$style_id = 0;
}
Comment on lines +55 to +58
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, $parent_gui->getObject()->getStyleSheetId() already defaults to 0 and never null.

See: ilObjStyleSheet::lookupObjectStyle

$tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET",
ilObjStyleSheet::getContentStylePath($parent_gui->getObject()->getStyleSheetId())
ilObjStyleSheet::getContentStylePath($style_id))
);
$tpl->parseCurrentBlock();
}
Expand Down
10 changes: 5 additions & 5 deletions classes/Content/class.xudfContentElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public static function find($primary_key, array $add_constructor_args = []): ?se
* @con_length 8
* @con_is_notnull true
*/
protected int $obj_id;
protected ?int $obj_id = null;

/**
* @con_has_field true
* @con_fieldtype integer
* @con_length 8
*/
protected int $sort;
protected int $sort = 0;

/**
* @con_has_field true
Expand All @@ -79,21 +79,21 @@ public static function find($primary_key, array $add_constructor_args = []): ?se
* @con_fieldtype integer
* @con_length 8
*/
protected int $udf_field;
protected ?int $udf_field = null;

/**
* @con_has_field true
* @con_fieldtype text
* @con_length 256
*/
protected string $title;
protected string $title = "";

/**
* @con_has_field true
* @con_fieldtype text
* @con_length 256
*/
protected string $description;
protected string $description = "";

/**
* @con_has_field true
Expand Down
8 changes: 4 additions & 4 deletions classes/Content/class.xudfContentFormGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ protected function initForm($editable): void

switch ($definition['field_type']) {
case 1:
$input = new ilTextInputGUI($element->getTitle(), $element->getUdfFieldId());
$input = new ilTextInputGUI($element->getTitle(), (string) $element->getUdfFieldId());
break;
case 2:
$input = new ilSelectInputGUI($element->getTitle(), $element->getUdfFieldId());
$input = new ilSelectInputGUI($element->getTitle(), (string) $element->getUdfFieldId());
$options = ['' => $this->dic->language()->txt('please_choose')];
foreach ($definition['field_values'] as $key => $values) {
$options[$values] = $values;
}
$input->setOptions($options);
break;
case 3:
$input = new ilTextAreaInputGUI($element->getTitle(), $element->getUdfFieldId());
$input = new ilTextAreaInputGUI($element->getTitle(), (string) $element->getUdfFieldId());
break;
case 51:
$input = ilCustomUserFieldsHelper::getInstance()->getFormPropertyForDefinition($definition, true);
Expand Down Expand Up @@ -130,7 +130,7 @@ public function saveForm(): bool

/** @var xudfContentElement $element */
foreach (xudfContentElement::where(['obj_id' => $this->obj_id, 'is_separator' => false])->get() as $element) {
$value = $this->getInput($element->getUdfFieldId());
$value = $this->getInput((string) $element->getUdfFieldId());

if ($value === null) {
$value = $this->getInput("udf_" . $element->getUdfFieldId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public function __construct(xudfFormConfigurationGUI $parent_gui, xudfContentEle
protected function initForm(): void
{
$input = new ilHiddenInputGUI(self::F_IS_SEPARATOR);
$input->setValue($this->element->isSeparator());
$input->setValue((string) $this->element->isSeparator());
$this->addItem($input);

if ($this->element->getId()) {
$input = new ilHiddenInputGUI(self::F_ELEMENT_ID);
$input->setValue($this->element->getId());
$input->setValue((string) $this->element->getId());
$this->addItem($input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function addSeparator(): void
protected function create(): void
{
$element = new xudfContentElement($_POST['element_id']);
$element->setIsSeparator($_POST[xudfFormConfigurationFormGUI::F_IS_SEPARATOR]);
$element->setIsSeparator((bool) $_POST[xudfFormConfigurationFormGUI::F_IS_SEPARATOR]);

$xudfFormConfigurationFormGUI = new xudfFormConfigurationFormGUI($this, $element);
$xudfFormConfigurationFormGUI->setValuesByPost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,23 @@ public function __construct(object $parent_gui, string $parent_cmd)
$this->dic->ui()->mainTemplate()->addOnLoadCode("xudf = {'base_link': '$base_link'};");

$this->initColumns();
$this->setData(xudfContentElement::where(['obj_id' => ilObjUdfEditor::_lookupObjectId(filter_input(INPUT_GET, 'ref_id'))])->orderBy('sort')->getArray());

try {
$this->setData(xudfContentElement::where(['obj_id' => ilObjUdfEditor::_lookupObjectId((int) filter_input(INPUT_GET, 'ref_id'))])->orderBy('sort')->getArray());
} catch (Exception $e) {
$this->setData([]);
}
}

protected function initColumns(): void
{
$this->addColumn('', '', 10, true);
$this->addColumn($this->dic->language()->txt('title'), 'title', 50);
$this->addColumn($this->dic->language()->txt('description'), 'description', 100);
$this->addColumn($this->dic->language()->txt('type'), 'type', 30);
$this->addColumn($this->pl->txt('udf_type'), 'udf_type', 30);
$this->addColumn($this->pl->txt('is_required'), 'is_required', 30);
$this->addColumn('', '', 10, true);
$this->addColumn('', '', "10", true);
$this->addColumn($this->dic->language()->txt('title'), 'title', "50");
$this->addColumn($this->dic->language()->txt('description'), 'description', "100");
$this->addColumn($this->dic->language()->txt('type'), 'type', "30");
$this->addColumn($this->pl->txt('udf_type'), 'udf_type', "30");
$this->addColumn($this->pl->txt('is_required'), 'is_required', "30");
$this->addColumn('', '', "10", true);
}

protected function fillRow(array $a_set): void
Expand Down
6 changes: 3 additions & 3 deletions classes/Settings/class.xudfSettingsFormGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public function saveForm(): bool
$this->parent_gui->getObject()->setDescription($this->getInput(self::F_DESCRIPTION));
$this->parent_gui->getObject()->update();

$this->xudfSetting->setIsOnline($this->getInput(self::F_ONLINE));
$this->xudfSetting->setShowInfoTab($this->getInput(self::F_SHOW_INFOTAB));
$this->xudfSetting->setMailNotification($this->getInput(self::F_MAIL_NOTIFICATION));
$this->xudfSetting->setIsOnline((bool) $this->getInput(self::F_ONLINE));
$this->xudfSetting->setShowInfoTab((bool) $this->getInput(self::F_SHOW_INFOTAB));
$this->xudfSetting->setMailNotification((bool) $this->getInput(self::F_MAIL_NOTIFICATION));
$this->xudfSetting->setAdditionalNotification($this->getInput(self::F_ADDITIONAL_NOTIFICATION));
$this->xudfSetting->setRedirectType($this->getInput(self::F_REDIRECT_TYPE));
switch ($this->xudfSetting->getRedirectType()) {
Expand Down
2 changes: 1 addition & 1 deletion classes/class.ilObjUdfEditorAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct()
public function _checkAccess(string $a_cmd, string $a_permission, ?int $a_ref_id = null, ?int $a_obj_id = null, ?int $a_user_id = null): bool
{
if ($a_ref_id === null) {
$a_ref_id = filter_input(INPUT_GET, "ref_id");
$a_ref_id = (int) filter_input(INPUT_GET, "ref_id");
}

if ($a_obj_id === null) {
Expand Down
6 changes: 3 additions & 3 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ fold_create_xudf#:#UdfEditor Erstellen
grp_create_xudf#:#UdfEditor Erstellen
root_create_xudf#:#UdfEditor Erstellen
xudf_visible#:#Anzeigen: UdfEditor ist sichtbar
xudf_read#:#Lesezugriff: Videos können angezeigt werden
xudf_read#:#Lesezugriff: Inhalte können gesehen werden
xudf_copy#:#Kopieren: UdfEditor kann kopiert werden
xudf_write#:#Einstellungen bearbeiten: Einstellungen und Inhalte können bearbeitet werden
xudf_delete#:#Löschen: Objekt kann gelöscht werden
xudf_edit_permission#:#Rechteeinstellungen ändern: Rechteeinstellungen ändern
Expand All @@ -49,7 +50,6 @@ stay_in_form#:#Im Formular bleiben
to_ilias_object#:#ILIAS-Objekt
to_url#:#URL
notification#:#Benachrichtigung

notifications4plugin_actions#:#Aktionen
notifications4plugin_add#:#Hinzugefügen
notifications4plugin_add_notification#:#Benachrichtigung hinzufügen
Expand Down Expand Up @@ -80,4 +80,4 @@ notifications4plugin_saved_notification#:#Benachrichtigung %s gespeichert
notifications4plugin_subject#:#Betreff
notifications4plugin_template_selection#:#Benachrichtigungs-Vorlage
notifications4plugin_text#:#Text
notifications4plugin_title#:#Titel
notifications4plugin_title#:#Titel
6 changes: 3 additions & 3 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ fold_create_xudf#:#Create UdfEditor
grp_create_xudf#:#Create UdfEditor
root_create_xudf#:#Create UdfEditor
xudf_visible#:#Visible: UdfEditor is visible
xudf_read#:#Read: User can watch the videos
xudf_read#:#Read: User can see UdfEditor content
xudf_copy#:#Copy: User can copy UdfEditor object
xudf_rep_robj_xudf_perm_upload#:#Upload: User can upload videos
xudf_write#:#Edit Settings: User can edit content and settings of UdfEditor object
xudf_delete#:#Delete: User can delete UdfEditor object
Expand All @@ -50,7 +51,6 @@ stay_in_form#:#stay in form
to_ilias_object#:#to ILIAS object
to_url#:#to URL
notification#:#Notification

notifications4plugin_actions#:#Actions
notifications4plugin_add#:#Add
notifications4plugin_add_notification#:#Add notification
Expand Down Expand Up @@ -81,4 +81,4 @@ notifications4plugin_saved_notification#:#Notification %s saved
notifications4plugin_subject#:#Subject
notifications4plugin_template_selection#:#Notification template
notifications4plugin_text#:#Text
notifications4plugin_title#:#Title
notifications4plugin_title#:#Title
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ private static function fixCtrlNamespaceCurrentUrl(): void
self::$has_fix_ctrl_namespace_current_url = true;

// Fix language select meta bar which current ctrl gui has namespaces (public page)
$_SERVER["REQUEST_URI"] = str_replace("\\", "%5C", $_SERVER["REQUEST_URI"]);
if (isset($_SERVER["REQUEST_URI"])) {
$_SERVER["REQUEST_URI"] = str_replace("\\", "%5C", $_SERVER["REQUEST_URI"]);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ public static function getValueForLang(array $values, /*?*/ string $lang_key = n
$lang_key = $DIC->language()->getLangKey();
}

$value = $values[$lang_key];
$value = $values[$lang_key] ?? "";

if (!empty($sub_key)) {
if (!is_array($value)) {
$value = [];
}

$value = $value[$sub_key];
$value = $value[$sub_key] ?? "";
}

if (!empty($value)) {
Expand Down
7 changes: 4 additions & 3 deletions libs/Notifications4Plugin/src/Sender/InternalMailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ public function send(): void
//$errors = $this->mailer->sendMail(, $this->getCc(), $this->getBcc(), $this->getSubject(), $this->getMessage(), [], false);

if (!empty($errors)) {
foreach ($errors as $mailError) {
$this->dic->logger()->root()->error($this->dic->language()->txt($mailError->getLanguageVariable()));
}
$error = $errors[0];
if ($error instanceof ilMailError) {
throw new ilMailException($this->dic->language()->txt($error->getLanguageVariable()));
} else {
if (!$error instanceof ilMailError) {
if ($error instanceof Throwable) {
throw $error;
} else {
Expand Down