-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a notifications field in the people table
Updates #144
- Loading branch information
Showing
7 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
alter table eventTypes add cifsType varchar(128); | ||
alter table events add foreign key (eventType_id) references eventTypes(id); | ||
alter table events add foreign key (eventType_id) references eventTypes(id); | ||
alter table people add notifications boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<?php | ||
/** | ||
* @copyright 2013 City of Bloomington, Indiana | ||
* @copyright 2014-2018 City of Bloomington, Indiana | ||
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt | ||
* @author Cliff Ingham <[email protected]> | ||
*/ | ||
namespace Application\Models; | ||
|
||
|
@@ -34,6 +33,11 @@ public function find($fields=null, $order='lastname', $paginated=false, $limit=n | |
} | ||
break; | ||
|
||
case 'notifications': | ||
if ($value) { $select->where('notifications = 1'); } | ||
else { $select->where('notifications != 1'); } | ||
break; | ||
|
||
default: | ||
$select->where([$key=>$value]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<?php | ||
/** | ||
* @copyright 2009-2015 City of Bloomington, Indiana | ||
* @copyright 2009-2018 City of Bloomington, Indiana | ||
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt | ||
* @author Cliff Ingham <[email protected]> | ||
*/ | ||
namespace Application\Models; | ||
use Blossom\Classes\ActiveRecord; | ||
|
@@ -96,9 +95,7 @@ public function save() | |
*/ | ||
public function deleteUserAccount() | ||
{ | ||
$userAccountFields = array( | ||
'username', 'password', 'authenticationMethod', 'role' | ||
); | ||
$userAccountFields = ['username', 'password', 'authenticationMethod', 'role']; | ||
foreach ($userAccountFields as $f) { | ||
$this->data[$f] = null; | ||
} | ||
|
@@ -123,12 +120,14 @@ public function getUsername() { return parent::get('username'); } | |
public function getPassword() { return parent::get('password'); } # Encrypted | ||
public function getRole() { return parent::get('role'); } | ||
public function getAuthenticationMethod() { return parent::get('authenticationMethod'); } | ||
public function getNotifications(): int { return parent::get('notifications') ? 1 : 0; } | ||
public function getDepartment_id() { return parent::get('getDepartment_id'); } | ||
public function getDepartment() { return parent::getForeignKeyObject(__namespace__.'\Department', 'department_id'); } | ||
|
||
public function setUsername ($s) { parent::set('username', $s); } | ||
public function setRole ($s) { parent::set('role', $s); } | ||
public function setAuthenticationMethod($s) { parent::set('authenticationMethod', $s); } | ||
public function setNotifications ($b) { parent::set('notifications', $b ? 1 : 0); } | ||
public function setDepartment_id($i) { parent::setForeignKeyField (__namespace__.'\Department', 'department_id', $i); } | ||
public function setDepartment ($i) { parent::setForeignKeyObject(__namespace__.'\Department', 'department_id', $i); } | ||
|
||
|
@@ -144,7 +143,7 @@ public function setPassword($s) | |
*/ | ||
public function handleUpdate($post) | ||
{ | ||
$fields = array( 'firstname', 'middlename', 'lastname', 'email', 'phone' ); | ||
$fields = ['firstname', 'middlename', 'lastname', 'email', 'phone', 'notifications']; | ||
foreach ($fields as $field) { | ||
if (isset($post[$field])) { | ||
$set = 'set'.ucfirst($field); | ||
|
@@ -158,10 +157,10 @@ public function handleUpdate($post) | |
*/ | ||
public function handleUpdateUserAccount($post) | ||
{ | ||
$fields = array( | ||
$fields = [ | ||
'firstname', 'lastname', 'email', 'phone', 'department_id', | ||
'username', 'authenticationMethod', 'role' | ||
); | ||
]; | ||
|
||
foreach ($fields as $f) { | ||
if (isset($post[$f])) { | ||
|
@@ -277,4 +276,5 @@ public function populateFromExternalIdentity(ExternalIdentity $identity) | |
$this->setPhone($identity->getPhone()); | ||
} | ||
} | ||
|
||
} |