diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3d90183d..c83ba32f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,9 +1,10 @@ Changelog ========= -Unreleased +1.10.4 (Unreleased) --------------------- - Fix #328: Missing Iframe attributes in snippet +- Fix #333: Fix saving of iframe URL by space admin 1.10.3 (May 15, 2024) --------------------- diff --git a/models/CustomContentContainer.php b/models/CustomContentContainer.php index 758170e9..fd88778e 100644 --- a/models/CustomContentContainer.php +++ b/models/CustomContentContainer.php @@ -23,15 +23,15 @@ * Note: Subclasses may container global types not bound to any ContentContainerActiveRecord * * The followings are the available columns in table 'custom_pages_page': - * @property integer $id - * @property integer $type + * @property int $id + * @property int $type * @property string $title * @property string $icon * @property string $page_content * @property string $iframe_attrs - * @property integer $sort_order - * @property integer $admin_only - * @property integer $in_new_window + * @property int $sort_order + * @property int $admin_only + * @property int $in_new_window * @property string $target * @property string $cssClass * @property string $url @@ -41,9 +41,9 @@ abstract class CustomContentContainer extends ContentActiveRecord use PhpPageContainer; use TemplatePageContainer; - const VISIBILITY_ADMIN_ONLY = 3; - const VISIBILITY_PRIVATE = 0; - const VISIBILITY_PUBLIC = 1; + public const VISIBILITY_ADMIN_ONLY = 3; + public const VISIBILITY_PRIVATE = 0; + public const VISIBILITY_PUBLIC = 1; /** * @inheritdoc @@ -56,7 +56,7 @@ abstract class CustomContentContainer extends ContentActiveRecord private $_target; /** - * @var integer special field for template based pages specifying the layout template id + * @var int special field for template based pages specifying the layout template id */ public $templateId; @@ -71,7 +71,7 @@ public function afterFind() if ($this->admin_only) { $this->visibility = static::VISIBILITY_ADMIN_ONLY; - } else if ($this->content->isPublic()) { + } elseif ($this->content->isPublic()) { $this->visibility = static::VISIBILITY_PUBLIC; } else { $this->visibility = static::VISIBILITY_PRIVATE; @@ -81,7 +81,7 @@ public function afterFind() /** * Returns the database content field. Note this does not render the any content. */ - public abstract function getPageContent(); + abstract public function getPageContent(); /** * Returns the database content field. Note this does not render the any content. @@ -94,29 +94,29 @@ public function getPageContentProperty() /** * Returns all allowed templates for a page container class. */ - public abstract function getAllowedTemplateSelection(); + abstract public function getAllowedTemplateSelection(); /** * Returns the page container class label. * @return string */ - public abstract function getLabel(); + abstract public function getLabel(); /** * Returns the view file path for PHP based content. * @return string */ - public abstract function getPhpViewPath(); + abstract public function getPhpViewPath(); /** * @return string */ - public abstract function getEditUrl(); + abstract public function getEditUrl(); /** * @return string */ - public abstract function getPageType(); + abstract public function getPageType(); /** * @return array @@ -124,7 +124,7 @@ public abstract function getPageType(); public function getVisibilitySelection() { $result = [ - static::VISIBILITY_ADMIN_ONLY => Yii::t('CustomPagesModule.visibility', 'Admin only') + static::VISIBILITY_ADMIN_ONLY => Yii::t('CustomPagesModule.visibility', 'Admin only'), ]; if ($this->isGuestAccessEnabled()) { @@ -142,7 +142,7 @@ public function getVisibilitySelection() /** * Helper function can be replaced with AuthHelper::isGuestAccessEnabled() after min-version 1.4 * - * @return boolean + * @return bool */ protected function isGuestAccessEnabled() { @@ -174,7 +174,7 @@ public function defaultAttributeLabels() 'targetUrl' => Yii::t('CustomPagesModule.components_Container', 'Target Url'), 'templateId' => Yii::t('CustomPagesModule.components_Container', 'Template Layout'), 'admin_only' => Yii::t('CustomPagesModule.models_Page', 'Only visible for admins'), - 'visibility' => Yii::t('CustomPagesModule.models_Page', 'Visibility') + 'visibility' => Yii::t('CustomPagesModule.models_Page', 'Visibility'), ]; } @@ -241,7 +241,11 @@ private function getRulesByContentType() return $result; } - if (PhpType::isType($type) || LinkType::isType($type) || HtmlType::isType($type) || MarkdownType::isType($type) || IframeType::isType($type)) { + if (PhpType::isType($type) || + LinkType::isType($type) || + HtmlType::isType($type) || + MarkdownType::isType($type) || + (IframeType::isType($type) && Yii::$app->user->isAdmin())) { $result[] = ['page_content', 'required']; } diff --git a/models/IframeType.php b/models/IframeType.php index 2f30fd77..f64ce8fb 100644 --- a/models/IframeType.php +++ b/models/IframeType.php @@ -8,29 +8,26 @@ namespace humhub\modules\custom_pages\models; - use Yii; use yii\widgets\ActiveForm; class IframeType extends ContentType { - - const ID = 3; + public const ID = 3; protected $hasContent = false; - - function getId() + public function getId() { return static::ID; } - function getLabel() + public function getLabel() { return Yii::t('CustomPagesModule.base', 'Iframe'); } - function getDescription() + public function getDescription() { return Yii::t('CustomPagesModule.base', 'Will embed the the result of a given url as an iframe element.'); } @@ -47,18 +44,19 @@ public function getViewName() public function renderFormField(ActiveForm $form, CustomContentContainer $page) { - $targetUrlField = $form->field($page, $page->getPageContentProperty())->label($page->getAttributeLabel('targetUrl')); - if ($page->iframe_attrs && !Yii::$app->user->isAdmin()) { - $formField = $targetUrlField->textInput(['class' => 'form-control', 'disabled' => 'disabled'])->hint(Yii::t('CustomPagesModule.views_common_edit', 'You need to be a system administrator to edit this URL')); - } else { - $formField = $targetUrlField->textInput(['class' => 'form-control'])->hint(Yii::t('CustomPagesModule.views_common_edit', 'e.g. http://www.example.de')); - } + $targetUrlField = $form->field($page, $page->getPageContentProperty()) + ->label($page->getAttributeLabel('targetUrl')); if (Yii::$app->user->isAdmin()) { - $formField .= - $form->field($page, 'iframe_attrs')->textInput(['class' => 'form-control'])->hint(Yii::t('CustomPagesModule.views_common_edit', 'e.g. allowfullscreen allow="camera; microphone"')); + $formField = $targetUrlField + ->hint(Yii::t('CustomPagesModule.views_common_edit', 'e.g. http://www.example.de')); + $formField .= $form->field($page, 'iframe_attrs') + ->hint(Yii::t('CustomPagesModule.views_common_edit', 'e.g. allowfullscreen allow="camera; microphone"')); + } else { + $formField = $targetUrlField->textInput(['disabled' => 'disabled']) + ->hint(Yii::t('CustomPagesModule.views_common_edit', 'You need to be a system administrator to edit this URL')); } return $formField; } -} \ No newline at end of file +} diff --git a/module.json b/module.json index d796c995..002ad690 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "Custom Pages", "description": "Create custom pages and widgets and share them with your users. Take advantage of a wide range of editing options, including HTML and Markdown.", "keywords": ["pages", "custom", "iframe", "markdown", "link", "navigation", "spaces"], - "version": "1.10.3", + "version": "1.10.4", "homepage": "https://github.com/humhub/custom-pages", "humhub": { "minVersion": "1.14"