diff --git a/.github/workflows/codeception-min-version.yml b/.github/workflows/codeception-min-version.yml index efb2aa71..8826b231 100644 --- a/.github/workflows/codeception-min-version.yml +++ b/.github/workflows/codeception-min-version.yml @@ -13,3 +13,4 @@ jobs: with: module-id: polls use-rest-module: true + rest-module-branch: develop diff --git a/Events.php b/Events.php index 88479d04..cd38faf1 100644 --- a/Events.php +++ b/Events.php @@ -143,8 +143,7 @@ public static function onSampleDataInstall($event) $comment = new \humhub\modules\comment\models\Comment(); $comment->message = Yii::t('PollsModule.base', "Why don't we go to Bemelmans Bar?"); - $comment->object_model = $poll->className(); - $comment->object_id = $poll->getPrimaryKey(); + $comment->content_id = $poll->content->id; $comment->save(); // Switch Identity @@ -155,8 +154,7 @@ public static function onSampleDataInstall($event) $comment = new \humhub\modules\comment\models\Comment(); $comment->message = Yii::t('PollsModule.base', "Again? :weary:"); - $comment->object_model = $poll->className(); - $comment->object_id = $poll->getPrimaryKey(); + $comment->content_id = $poll->content->id; $comment->save(); // Switch Identity diff --git a/Module.php b/Module.php index e142827e..2090e513 100644 --- a/Module.php +++ b/Module.php @@ -2,7 +2,6 @@ namespace humhub\modules\polls; -use humhub\components\console\Application as ConsoleApplication; use humhub\modules\user\models\User; use humhub\modules\polls\models\Poll; use humhub\modules\space\models\Space; @@ -26,19 +25,6 @@ class Module extends ContentContainerModule */ public $resourcesPath = 'resources'; - /** - * @inheritdoc - */ - public function init() - { - parent::init(); - - if (Yii::$app instanceof ConsoleApplication) { - // Prevents the Yii HelpCommand from crawling all web controllers and possibly throwing errors at REST endpoints if the REST module is not available. - $this->controllerNamespace = 'polls/commands'; - } - } - /** * @inheritdoc */ diff --git a/activities/NewVote.php b/activities/NewVote.php index f9466b11..6c38f3fd 100644 --- a/activities/NewVote.php +++ b/activities/NewVote.php @@ -1,43 +1,29 @@ '' . Html::encode($originator->displayName) . '', - '{question}' => $this->context->getContentInfo($source) -]); -?> diff --git a/controllers/PollController.php b/controllers/PollController.php index 051adc33..347d4814 100644 --- a/controllers/PollController.php +++ b/controllers/PollController.php @@ -6,7 +6,7 @@ use humhub\modules\polls\models\Poll; use humhub\modules\polls\models\PollAnswer; use humhub\modules\polls\widgets\WallCreateForm; -use humhub\modules\stream\actions\Stream; +use humhub\modules\stream\actions\StreamEntryResponse; use humhub\modules\user\models\User; use humhub\modules\user\widgets\UserListBox; use humhub\helpers\Html; @@ -67,7 +67,7 @@ public function actionReload($id) throw new HttpException(403); } - return $this->asJson(Stream::getContentResultEntry($model->content)); + return $this->asJson(StreamEntryResponse::getAsArray($model->content)); } public function actionEdit() @@ -95,7 +95,7 @@ public function actionEdit() if ($model->validate() && $model->save()) { // Reload record to get populated updated_at field $model = Poll::findOne(['id' => $id]); - return Stream::getContentResultEntry($model->content); + return StreamEntryResponse::getAsArray($model->content); } else { $result['errors'] = $model->getErrors(); } @@ -131,7 +131,7 @@ public function setClosed($id, $closed) // Refresh updated_at $model->content->refresh(); - return Stream::getContentResultEntry($model->content); + return StreamEntryResponse::getAsArray($model->content); } /** @@ -159,7 +159,7 @@ public function actionAnswer() $poll->vote($votes); - return Stream::getContentResultEntry($poll->content); + return StreamEntryResponse::getAsArray($poll->content); } /** @@ -169,7 +169,7 @@ public function actionAnswerReset() { $poll = $this->getPollByParameter(); $poll->resetAnswer(); - return $this->asJson(Stream::getContentResultEntry($poll->content)); + return $this->asJson(StreamEntryResponse::getAsArray($poll->content)); } /** diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index eeff39a3..cfae92ef 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,7 +1,15 @@ Changelog ========= -1.4.5 (Feburary 27, 2026) +1.5.1 (July 23, 2026) +--------------------- +- Fix #175: Error creating installer sample content (comment no longer uses removed `object_model`/`object_id` properties) + +1.5.0 (June 5, 2026) +-------------------- +- Enh #174: Update for HumHub 1.19 + +1.4.5 (February 27, 2026) ------------------------- - Fix #173: Alignment on large screens and Enterprise Theme diff --git a/docs/README.md b/docs/README.md index 8c4f7df3..f8a666f6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,3 @@ -[](https://github.com/humhub/polls/actions/workflows/php-test-master.yml) - # Polls Easily create polls with the intuitive Polls Module, simplifying decision-making on your network. Whether you're seeking opinions on urgent matters or aiming for consensus, harness the power of voting to streamline discussions and swiftly resolve disputes. @@ -10,3 +8,4 @@ Easily create polls with the intuitive Polls Module, simplifying decision-making - **Vote Types:** Choose between regular and anonymous voting. - **Choices:** Allow your users to select single or multiple options. - **Blind Voting:** Keep poll results hidden until it's closed to avoid choice bias. + diff --git a/migrations/m150709_151858_namespace.php b/migrations/m150709_151858_namespace.php index 58d0d3cb..09423509 100644 --- a/migrations/m150709_151858_namespace.php +++ b/migrations/m150709_151858_namespace.php @@ -1,15 +1,24 @@ renameClass('Poll', humhub\modules\polls\models\Poll::className()); - $this->update('activity', ['class' => 'humhub\modules\content\activities\ContentCreated', 'module' => 'content'], ['class' => 'PollCreated']); - $this->update('activity', ['class' => 'humhub\modules\polls\activities\NewVote', 'module' => 'polls'], ['class' => 'PollAnswered']); + $this->renameClass('Poll', Poll::class); + + $table = $this->db->getTableSchema('activity'); + $columnsContentCreated = ['class' => 'humhub\modules\content\activities\ContentCreated']; + $columnsNewVote = ['class' => 'humhub\modules\polls\activities\NewVote']; + if (isset($table->columns['module'])) { + $columnsContentCreated['module'] = 'content'; + $columnsNewVote['module'] = 'polls'; + } + + $this->update('activity', $columnsContentCreated, ['class' => 'PollCreated']); + $this->update('activity', $columnsNewVote, ['class' => 'PollAnswered']); } public function down() diff --git a/models/Poll.php b/models/Poll.php index e43ce5ab..6b05b9bb 100644 --- a/models/Poll.php +++ b/models/Poll.php @@ -2,9 +2,10 @@ namespace humhub\modules\polls\models; +use humhub\modules\activity\services\ActivityManager; use humhub\modules\content\widgets\richtext\RichText; +use humhub\modules\polls\activities\NewVote; use humhub\modules\polls\permissions\CreatePoll; -use humhub\modules\search\interfaces\Searchable; use humhub\modules\content\components\ContentActiveRecord; use Yii; @@ -32,7 +33,7 @@ * @since 0.5 * @author Luke */ -class Poll extends ContentActiveRecord implements Searchable +class Poll extends ContentActiveRecord { public const MIN_REQUIRED_ANSWERS = 2; public const SCENARIO_CREATE = 'create'; @@ -309,10 +310,7 @@ public function vote($votes = []) } if ($voted && !$this->anonymous) { - $activity = new \humhub\modules\polls\activities\NewVote(); - $activity->source = $this; - $activity->originator = Yii::$app->user->getIdentity(); - $activity->create(); + ActivityManager::dispatch(NewVote::class, $this); } return $voted; diff --git a/module.json b/module.json index b99eed71..f7e01d67 100644 --- a/module.json +++ b/module.json @@ -3,10 +3,9 @@ "name": "Polls", "description": "Easily create polls, streamline decision-making, and harness the power of voting.", "keywords": ["poll", "voting", "decision making"], - "version": "1.4.5", + "version": "1.5.1", "humhub": { - "minVersion": "1.18.1", - "maxVersion": "1.18" + "minVersion": "1.19" }, "homepage": "https://github.com/humhub/polls", "authors": [ diff --git a/widgets/views/closeButton.php b/widgets/views/closeButton.php index dc3f2b34..6d4b4d53 100644 --- a/widgets/views/closeButton.php +++ b/widgets/views/closeButton.php @@ -1,15 +1,18 @@ +