Skip to content
Merged
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
69 changes: 10 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
![lint](https://github.com/nextcloud/polls/actions/workflows/lint.yml/badge.svg)

[![Dependabot status](https://img.shields.io/badge/Dependabot-enabled-brightgreen.svg?longCache=true&style=flat-square&logo=dependabot)](https://dependabot.com)
[![Software License](https://img.shields.io/badge/license-AGPL-brightgreen.svg?style=flat-square)](COPYING)
[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud/polls)](https://api.reuse.software/info/github.com/nextcloud/polls)
[![Software License](https://img.shields.io/badge/license-AGPL-brightgreen.svg?style=flat-square)](COPYING)
[![Nextcloud21+](https://img.shields.io/badge/Nextcloud%20Version-21%2B-0082C9?logo=nextcloud)](https://nextcloud.com)

# Free meeting schedule tool
- :next_track_button: Easy poll creation
- :hammer_and_wrench: Highly customizable
- :envelope: Make your poll confidential by hiding the results until you want them to be discovered
- :dark_sunglasses: Obfuscate participants' names from other participants
- :dark_sunglasses: Obfuscate participants' names from other participants or set strong anonymous mode
- :timer_clock: Set an automatic expiry date
- :heavy_plus_sign: Allow participants to add more options
- :white_check_mark: Limit votes per option or user
Expand All @@ -34,23 +35,14 @@
- Contacts
- Activity

## Installation / Update
This app is supposed to work on Nextcloud version 21+.
Find Polls in the [Nextcloud app store](https://apps.nextcloud.com/apps/polls).

### Install latest release
You can download and install the latest release from the [Nextcloud app store](https://apps.nextcloud.com/apps/polls).
## Installation / Update
See [wiki](https://github.com/nextcloud/polls/wiki/Installation-help).

## Available occ commands
| Command | Description |
| - | - |
| `polls:db:clean-migrations` | Remove obsolete migrations, which are no more needed |
| `polls:db:purge` | Drop Polls' tables and remove migration and settings records |
| `polls:db:rebuild` | Rebuild Polls' database including indices |
| `polls:index:create` | Create all necessary indices and foreign key constraints |
| `polls:index:remove` | Remove all indices |
| `polls:poll:transfer-ownership <source-user> <target-user>` | Transfer poll ownership from <source-user> to <target-user> |
| `polls:share:add [--user USER] [--group GROUP] [--email EMAIL] [--] <id>` | Add user/group/email with <id> to shares |
| `polls:share:remove [--user USER] [--group GROUP] [--email EMAIL] [--] <id>` | Remove user/group/email with <id> from shares |
See [wiki](https://github.com/nextcloud/polls/wiki/OCC-commands).

## Support
- Report a bug or request a feature: https://github.com/nextcloud/polls/issues
- Community support: https://help.nextcloud.com/c/apps/polls/
Expand All @@ -60,49 +52,8 @@ Manage your polls and create new ones | Many configuration options | Share your
:-:|:-:|:-:|:-:
![Manage Polls](screenshots/overview.png) | ![Vote](screenshots/edit-poll.png) | ![Edit poll](screenshots/share.png) | ![Share poll](screenshots/vote.png)

## For the 7.x release branch (v7.x) please switch to the [master-7 branch](https://github.com/nextcloud/polls/tree/master-7)
### Install from git
If you want to run the latest development version from git source, you need to clone the repo to your apps folder:

```
git clone https://github.com/nextcloud/polls.git
```

* Install dev environment with ```make setup-dev``` or
* install runtime environment with ```make setup-build```
* Compile javascript with ```npm run build```
* Run a complete build with ```make appstore``` (Find the output in the build directory)
* call `occ app:enable polls` to enable Polls

### Installation variants

### First time install
Nextcloud executes
* unexecuted `migration classes` (not listed in the `*_migrations` table) and the
* `install` repair step.

### After a version update (changed version attribute in appinfo/info.xml)
Nextcloud executes
* `pre-migration` repair steps,
* unexecuted `migration classes` (not listed in the `*_migrations` table) and the
* `post-migration` repair steps

### Enabling already installed but disabled app without version change
Nextcloud executes
* `pre-migration` repair steps,
* unexecuted `migration classes` (not listed in the `*_migrations` table) and the
* `post-migration` repair steps and the
* `install` repair step

❗ As a compromise at the moment we allow the index creation to be ran twice when enabling the app via app store or `occ`, to ensure all indexes are created properly for every install/update/enabling path.

## Removing Polls from instance
Call `occ polls:db:purge` to remove Polls completely.
* removes all Polls related tables
* removes all Polls related migration records
* removes all Polls related app config records (this also disables Polls)

This does not remove Polls' files (call `occ app:remove polls` to remove it complete afterwards) but it resets Polls into an 'uninstalled' state. Enabling the app is then equivalent to a first time install and calls the migration and the install repair step (see above).
### Installation help
See [wiki](https://github.com/nextcloud/polls/wiki/Installation-help).

## Contribution Guidelines
Please read the [Code of Conduct](https://nextcloud.com/community/code-of-conduct/). This document offers some guidance to ensure Nextcloud participants can cooperate effectively in a positive and inspiring atmosphere, and to explain how together we can strengthen and support each other.
Expand Down
18 changes: 10 additions & 8 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<discussion>https://help.nextcloud.com/tag/polls-app</discussion>
<bugs>https://github.com/nextcloud/polls/issues</bugs>
<repository type="git">https://github.com/nextcloud/polls.git</repository>
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/master/screenshots/overview.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/master/screenshots/vote.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/master/screenshots/edit-poll.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/main/screenshots/overview.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/main/screenshots/vote.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/main/screenshots/edit-poll.png</screenshot>
<dependencies>
<php min-version="8.1"/>
<nextcloud min-version="30" max-version="31"/>
Expand All @@ -47,15 +47,17 @@
</install>
</repair-steps>
<commands>
<command>OCA\Polls\Command\Share\Add</command>
<command>OCA\Polls\Command\Share\Remove</command>
<command>OCA\Polls\Command\Db\CleanMigrations</command>
<command>OCA\Polls\Command\Db\CreateIndices</command>
<command>OCA\Polls\Command\Db\Purge</command>
<command>OCA\Polls\Command\Db\RemoveIndices</command>
<command>OCA\Polls\Command\Db\Rebuild</command>
<command>OCA\Polls\Command\Db\CreateIndices</command>
<command>OCA\Polls\Command\Db\CleanMigrations</command>
<command>OCA\Polls\Command\Db\RemoveFKConstraints</command>
<command>OCA\Polls\Command\Db\RemoveOptionalIndices</command>
<command>OCA\Polls\Command\Db\RemoveUniqueIndices</command>
<command>OCA\Polls\Command\Db\ResetWatch</command>
<command>OCA\Polls\Command\Poll\TransferOwnership</command>
<command>OCA\Polls\Command\Share\Add</command>
<command>OCA\Polls\Command\Share\Remove</command>
</commands>
<settings>
<admin>OCA\Polls\Settings\AdminSettings</admin>
Expand Down
10 changes: 5 additions & 5 deletions img/app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions img/polls-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions img/polls.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCA\Polls\Event\ShareTypeChangedEvent;
use OCA\Polls\Event\VoteEvent;
use OCA\Polls\Event\VoteSetEvent;
use OCA\Polls\Listener\AddMissingIndicesListener;
use OCA\Polls\Listener\CommentListener;
use OCA\Polls\Listener\GroupDeletedListener;
use OCA\Polls\Listener\OptionListener;
Expand All @@ -64,6 +65,7 @@
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Collaboration\Reference\RenderReferenceEvent;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\IAppConfig;
use OCP\IDBConnection;
Expand Down Expand Up @@ -91,6 +93,7 @@ public function register(IRegistrationContext $context): void {
include_once __DIR__ . '/../../vendor/autoload.php';
$this->registerServices($context);

$context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class);
$context->registerEventListener(RenderReferenceEvent::class, PollsReferenceListener::class);
$context->registerMiddleWare(RequestAttributesMiddleware::class);
$context->registerNotifierService(Notifier::class);
Expand Down
3 changes: 1 addition & 2 deletions lib/Command/Db/CleanMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class CleanMigrations extends Command {
protected string $name = parent::NAME_PREFIX . 'db:clean-migrations';
protected string $description = 'Remove old migrations entries from Nextcloud\'s migration table';
protected array $operationHints = [
'All polls tables will get checked against the current schema.',
'NO data migration will be executed, so make sure you have a backup of your database.',
'Note: NO data migration will be executed, so make sure you have a backup of your database.',
];

public function __construct(
Expand Down
13 changes: 7 additions & 6 deletions lib/Command/Db/CreateIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
class CreateIndices extends Command {
protected string $name = parent::NAME_PREFIX . 'index:create';
protected string $description = 'Add all indices and foreign key constraints';
protected string $description = 'Add unique indices and foreign key constraints';
protected array $operationHints = [
'Adds indices and foreing key constraints.',
'NO data migration will be executed, so make sure you have a backup of your database.',
'Adds unique indices and foreign key constraints.',
'To create the optional indices, run the command \'occ db:add-missing-indices\'',
'Note: NO data migration will be executed, so make sure you have a backup of your database.',
];

public function __construct(
Expand All @@ -38,7 +39,7 @@ protected function runCommands(): int {
$this->schema = $this->connection->createSchema();
$this->indexManager->setSchema($this->schema);
$this->addForeignKeyConstraints();
$this->addIndices();
$this->addUniqueIndices();
$this->connection->migrateToSchema($this->schema);

return 0;
Expand All @@ -56,9 +57,9 @@ private function addForeignKeyConstraints(): void {
/**
* Create index for $table
*/
private function addIndices(): void {
private function addUniqueIndices(): void {
$this->printComment('Add indices');
$messages = $this->indexManager->createIndices();
$messages = $this->indexManager->createUniqueIndices();
$this->printInfo($messages, ' - ');
}
}
4 changes: 4 additions & 0 deletions lib/Command/Db/Purge.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Purge extends Command {
' - delete Polls\'s app config records from oc_appconfig.',
' ',
'after running this command call \'occ app:remove polls \'',
'Note: Make sure you have a backup of your database.',
];

public function __construct(
Expand All @@ -38,6 +39,9 @@ protected function runCommands(): int {
$this->tableManager->setConnection($this->connection);
$messages = $this->tableManager->purgeTables();
$this->printInfo($messages, ' - ');
$this->printInfo($messages, 'Polls has been completely wiped off the database.');
$this->printInfo($messages, '');
$this->printInfo($messages, '!!! Now call \'occ app:remove polls \' to remove the app completely.');
return 0;
}
}
21 changes: 12 additions & 9 deletions lib/Command/Db/Rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ class Rebuild extends Command {
protected string $name = parent::NAME_PREFIX . 'db:rebuild';
protected string $description = 'Rebuilds poll\'s table structure';
protected array $operationHints = [
'All polls tables will get checked against the current schema.',
'NO data migration will be executed, so make sure you have a backup of your database.',
'',
'All polls tables will get checked and eventually updated against the current schema.',
'*****************************',
'** Please understand **',
'*****************************',
'The process will also recreate all indices and foreign key constraints.',
'The process will also remove all optional indices.',
'This can lead to a database performance impact on the app after the recreation is done.',
'',
'To recreate the optional indices, run the command \'occ db:add-missing-indices\'',
'Note: NO data migration will be executed, so make sure you have a backup of your database.',
];

public function __construct(
Expand Down Expand Up @@ -69,9 +70,11 @@ protected function runCommands(): int {
$this->printComment('Step 5. Remove invalid records (orphaned and duplicates)');
$this->cleanTables();

$this->printComment('Step 6. Recreate indices and foreign key constraints');
$this->printComment('Step 6. Recreate unique indices and foreign key constraints');
$this->addForeignKeyConstraints();
$this->addIndices();
$this->addUniqueIndices();

$this->printComment('Execute \'occ db:add-missing-indices\' to add missing optional indices');

$this->connection->migrateToSchema($this->schema);

Expand All @@ -90,9 +93,9 @@ private function addForeignKeyConstraints(): void {
/**
* Create index for $table
*/
private function addIndices(): void {
$this->printComment(' - Add indices');
$messages = $this->indexManager->createIndices();
private function addUniqueIndices(): void {
$this->printComment(' - Add unique indices');
$messages = $this->indexManager->createUniqueIndices();
$this->printInfo($messages, ' ');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
/**
* @psalm-api
*/
class RemoveIndices extends Command {
protected string $name = parent::NAME_PREFIX . 'index:remove';
protected string $description = 'Remove all indices and foreign key constraints';
class RemoveFKConstraints extends Command {
protected string $name = parent::NAME_PREFIX . 'index:remove:foreign-key-constraints';
protected string $description = 'Remove all foreign key constraints';
protected array $operationHints = [
'Removes all indices and foreign key constraints.',
'NO data migration will be executed, so make sure you have a backup of your database.',
'Remove all foreign key constraints.',
'*****************************',
'** Please understand **',
'*****************************',
'This can lead to inconsitent database states, because it affects the database integrity.',
'Therefoe this is highly NOT RECOMMENDED and should only be used if you know what you are doing.',
'',
'To recreate the Foreign key constraints, run the command \'occ ' . parent::NAME_PREFIX . 'index:create\'',
'Note: NO data migration will be executed, so make sure you have a backup of your database.',
];

public function __construct(
Expand All @@ -38,23 +45,13 @@ protected function runCommands(): int {
$this->indexManager->setSchema($this->schema);
$this->deleteForeignKeyConstraints();
$this->deleteGenericIndices();
$this->deleteUniqueIndices();
$this->deleteNamedIndices();
$this->connection->migrateToSchema($this->schema);
return 0;
}

/**
* remove on delete fk contraint from all tables referencing the main polls table
*/
private function deleteForeignKeyConstraints(): void {
$this->printComment('Remove foreign key constraints and generic indices');
$messages = $this->indexManager->removeAllForeignKeyConstraints();
$this->printInfo($messages, ' - ');
}

/**
* remove all generic indices
* remove all generic indices (the only generic indices should
* result from the FK Constraints)
*/
private function deleteGenericIndices(): void {
$this->printComment('Remove generic indices');
Expand All @@ -63,19 +60,11 @@ private function deleteGenericIndices(): void {
}

/**
* remove all unique indices
*/
private function deleteUniqueIndices(): void {
$this->printComment('Remove unique indices');
$messages = $this->indexManager->removeAllUniqueIndices();
$this->printInfo($messages, ' - ');
}
/**
* remove all named indices
* remove on delete fk contraint from all tables referencing the main polls table
*/
private function deleteNamedIndices(): void {
$this->printComment('Remove common indices');
$messages = $this->indexManager->removeNamedIndices();
private function deleteForeignKeyConstraints(): void {
$this->printComment('Remove foreign key constraints and generic indices');
$messages = $this->indexManager->removeAllForeignKeyConstraints();
$this->printInfo($messages, ' - ');
}
}
Loading