Skip to content

Commit cb1bc4c

Browse files
committed
Implemeted applications unarchive
Updates #258
1 parent cc899d5 commit cb1bc4c

File tree

5 files changed

+51
-11
lines changed

5 files changed

+51
-11
lines changed

access_control.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ $ZEND_ACL->allow('Reviewer', 'legislation', ['index', 'view', 'years', 'update']
8686
$ZEND_ACL->allow('Reviewer', ['legislationFiles', 'legislationActions', 'reports']);
8787
$ZEND_ACL->allow('Reviewer', 'legislationStatuses', 'index');
8888
$ZEND_ACL->allow('Reviewer', 'applicants', ['index', 'view', 'update']);
89-
$ZEND_ACL->allow('Reviewer', 'applications', ['index', 'archive', 'report']);
89+
$ZEND_ACL->allow('Reviewer', 'applications', ['index', 'archive', 'unarchive', 'report']);
9090
$ZEND_ACL->allow('Reviewer', 'people', 'viewContactInfo');
9191

9292
$ZEND_ACL->allow('Staff', 'committees', ['update']);

blocks/html/applications/partials/table.inc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* @copyright 2016 City of Bloomington, Indiana
4-
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
3+
* @copyright 2016-2020 City of Bloomington, Indiana
4+
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
55
* @param Zend\Db\Result $this->applications
66
* @param Committee $this->committee (optional)
77
* @param Applicant $this->applicant (optional)
@@ -26,6 +26,7 @@ use Application\Models\Person;
2626
$userCanViewApplications = Person::isAllowed('committees', 'applications');
2727
$userCanViewApplicant = Person::isAllowed('applicants', 'view');
2828
$userCanArchive = Person::isAllowed('applications', 'archive');
29+
$userCanUnArchive = Person::isAllowed('applications', 'unarchive');
2930
$userCanDelete = Person::isAllowed('applications', 'delete');
3031

3132
$helper = $this->template->getHelper('buttonLink');
@@ -62,7 +63,14 @@ use Application\Models\Person;
6263

6364
if ($this->type === 'archived') {
6465
$archived = $a->getArchived(DATE_FORMAT);
65-
echo "<td>$archived</td>";
66+
$button = '';
67+
if ($userCanUnArchive) {
68+
$button = $helper->buttonLink(
69+
BASE_URI.'/applications/unarchive?application_id='.$a->getId(),
70+
$this->_('application_unarchive')
71+
);
72+
}
73+
echo "<td>$archived $button</td>";
6674
}
6775
else {
6876
$expires = $a->getExpires(DATE_FORMAT);

language/en_US/LC_MESSAGES/labels.po

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,16 @@ msgid "application_add"
614614
msgstr "New Application"
615615

616616
msgid "application_edit"
617-
msgstr "Edit Application"
617+
msgstr "Edit"
618618

619619
msgid "application_delete"
620-
msgstr "Delete Application"
620+
msgstr "Delete"
621621

622622
msgid "application_archive"
623-
msgstr "Archive Application"
623+
msgstr "Archive"
624+
625+
msgid "application_unarchive"
626+
msgstr "Unarchive"
624627

625628
msgid "applications_current"
626629
msgstr "Current Applications"

src/Application/Controllers/ApplicationsController.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* @copyright 2016 City of Bloomington, Indiana
4-
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
3+
* @copyright 2016-2020 City of Bloomington, Indiana
4+
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
55
*/
66
namespace Application\Controllers;
77

@@ -38,6 +38,26 @@ public function archive()
3838
}
3939
}
4040

41+
public function unarchive()
42+
{
43+
if (!empty($_REQUEST['application_id'])) {
44+
try { $application = new Application($_REQUEST['application_id']); }
45+
catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; }
46+
}
47+
48+
if (isset($application)) {
49+
try { $application->unarchive(); }
50+
catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; }
51+
52+
header('Location: '.BASE_URI.'/committees/applications?committee_id='.$application->getCommittee_id());
53+
exit();
54+
}
55+
else {
56+
header('HTTP/1.1 404 Not Found', true, 404);
57+
$this->template->blocks[] = new Block('404.inc');
58+
}
59+
}
60+
4161
public function report()
4262
{
4363
if (!empty($_REQUEST['committee_id'])) {

src/Application/Models/Application.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* @copyright 2016 City of Bloomington, Indiana
4-
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
3+
* @copyright 2016-2020 City of Bloomington, Indiana
4+
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
55
*/
66
namespace Application\Models;
77

@@ -77,6 +77,15 @@ public function archive()
7777
}
7878
}
7979

80+
public function unarchive()
81+
{
82+
if ($this->getId()) {
83+
$sql = 'update applications set archived=null where id=?';
84+
$zend_db = Database::getConnection();
85+
$zend_db->query($sql, [$this->getId()]);
86+
}
87+
}
88+
8089
//----------------------------------------------------------------
8190
// Generic Getters & Setters
8291
//----------------------------------------------------------------

0 commit comments

Comments
 (0)