123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?php
- namespace Kanboard\Plugin\EncryptedContent\Controller;
- use Kanboard\Controller\BaseController;
- use Kanboard\Plugin\EncryptedContent\Model\EncryptedContentModel;
- /**
- *
- * @author Valentino Pesce
- *
- */
- class EncryptedContentController extends BaseController
- {
- public function noHTTPS()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $this->response->html($this->helper->layout->task('EncryptedContent:task/nohttps',
- [ 'form_headline' => t('This feature requires the use of an SSL certificate on the server'),
- 'task' => $task,
- 'project' => $project,
- ]
- )
- );
- }
- public function task()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $metadata = $this->encryptedContentModel->getAll($task['id']);
- $this->response->html($this->helper->layout->task('EncryptedContent:task/metadata',
- ['title' => t('Encrypted Content'),
- 'task' => $task,
- 'add_form' => true,
- 'project' => $project,
- 'metadata' => $metadata,
- ]
- )
- );
- }
- public function saveTask()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
-
- $encrypt = $this->helper->EncryptedContentHelper->EncryptedValue($values['value']);
- $this->encryptedContentModel->save($task['id'], [$encrypt]);
- $this->flash->success(t('Content created successfully'));
- return $this->response->redirect($this->helper->url->to('EncryptedContentController', 'task', ['plugin' => 'encryptedContent', 'task_id' => $task['id'], 'project_id' => $task['project_id']]), true);
- }
- public function updateTask()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
- $encrypt = $this->helper->EncryptedContentHelper->EncryptedValue($values['value']);
- $this->encryptedContentModel->save($task['id'], [$values['name'] => $encrypt]);
- $this->flash->success(t('Content updated successfully'));
- return $this->response->redirect($this->helper->url->to('EncryptedContentController', 'task', ['plugin' => 'encryptedContent', 'task_id' => $task['id'], 'project_id' => $task['project_id']]), true);
- }
- public function unlockTask()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $name = $this->request->getStringParam('name');
- $key = $this->request->getStringParam('key');
- $metadata = $this->encryptedContentModel->get($task['id'], $name);
- $this->response->html($this->template->render('encryptedContent:task/formunlock',
- [
- 'project' => $project,
- 'task' => $task,
- 'form_headline' => t('Unlock Encrypted Content'),
- 'values' => ['name' => $name, 'key' => $key, 'value' => $metadata],
- ]
- )
- );
- }
- public function decryptTask()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $values = $this->request->getValues();
- $metadata = $this->encryptedContentModel->get($task['id'], $values['name']);
- $this->response->html($this->template->render('encryptedContent:task/decryptcontent',
- [
- 'project' => $project,
- 'task' => $task,
- 'form_headline' => t('Content decrypt'),
- 'values' => ['name' => $values['name'], 'key' => $values['key'], 'value' => $metadata],
- ]
- )
- );
- }
- public function unlockEditTask()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $name = $this->request->getStringParam('name');
- $key = $this->request->getStringParam('key');
- $metadata = $this->encryptedContentModel->get($task['id'], $name);
- $this->response->html($this->template->render('encryptedContent:task/formunlockedit',
- [
- 'project' => $project,
- 'task' => $task,
- 'form_headline' => t('Unlock Encrypted Content'),
- 'values' => ['name' => $name, 'key' => $key, 'value' => $metadata],
- ]
- )
- );
- }
- public function editTask()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $values = $this->request->getValues();
- $metadata = $this->encryptedContentModel->get($task['id'], $values['name']);
- $this->response->html($this->template->render('encryptedContent:task/form',
- [
- 'project' => $project,
- 'task' => $task,
- 'form_headline' => t('Edit Encrypted Content'),
- 'values' => ['name' => $values['name'], 'key' => $values['key'], 'value' => $metadata],
- ]
- )
- );
- }
- public function removeTask()
- {
- $task = $this->getTask();
- $name = $this->request->getStringParam('name');
- if ($this->encryptedContentModel->remove($task['id'], $name)) {
- $this->flash->success(t('Content removed successfully'));
- } else {
- $this->flash->failure(t('Unable to remove'));
- }
- return $this->response->redirect($this->helper->url->to('EncryptedContentController', 'task', ['plugin' => 'encryptedContent', 'task_id' => $task['id'], 'project_id' => $task['project_id']]), true);
- }
- public function confirmTask()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $name = $this->request->getStringParam('name');
- $this->response->html($this->template->render('encryptedContent:task/remove',
- [
- 'task' => $task,
- 'project' => $project,
- 'name' => $name,
- ]
- )
- );
- }
- public function removeAllTask()
- {
- $task = $this->getTask();
- if ($this->encryptedContentModel->removeAll($task['id'])) {
- $this->flash->success(t('Content removed successfully'));
- } else {
- $this->flash->failure(t('Unable to remove'));
- }
- return $this->response->redirect($this->helper->url->to('EncryptedContentController', 'task', ['plugin' => 'encryptedContent', 'task_id' => $task['id'], 'project_id' => $task['project_id']]), true);
- }
- public function confirmAllTask()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $this->response->html($this->template->render('encryptedContent:task/removeall',
- [
- 'task' => $task,
- 'project' => $project,
- ]
- )
- );
- }
- public function randomKey()
- {
- $project = $this->getProject();
- $task = $this->getTask();
- $this->response->html($this->template->render('encryptedContent:task/randomkey',
- [
- 'task' => $task,
- 'project' => $project,
- ]
- )
- );
- }
- }
|