-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Messenger: added new Mailing List feature
- Loading branch information
Ross Parker
committed
Oct 17, 2024
1 parent
8585561
commit 4675919
Showing
10 changed files
with
509 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/* | ||
Gibbon: the flexible, open school platform | ||
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/) | ||
Copyright © 2010, Gibbon Foundation | ||
Gibbon™, Gibbon Education Ltd. (Hong Kong) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
use Gibbon\Services\Format; | ||
use Gibbon\Tables\DataTable; | ||
use Gibbon\Domain\Messenger\MailingListGateway; | ||
|
||
$page->breadcrumbs->add(__('Manage Mailing List')); | ||
|
||
if (isActionAccessible($guid, $connection2, '/modules/Messenger/mailingList_manage.php') == false) { | ||
// Access denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
//Proceed! | ||
|
||
// QUERY | ||
$mailingListGateway = $container->get(MailingListGateway::class); | ||
$criteria = $mailingListGateway->newQueryCriteria(true) | ||
->sortBy('surname', 'preferredName') | ||
->fromPOST(); | ||
|
||
$mailingLists = $mailingListGateway->queryMailingList($criteria); | ||
|
||
// TABLE | ||
$table = DataTable::createPaginated('mailingLists', $criteria); | ||
|
||
$table->addHeaderAction('add', __('Add')) | ||
->displayLabel() | ||
->setURL('/modules/Messenger/mailingList_manage_add.php'); | ||
|
||
$table->addColumn('surname', __('Surname')); | ||
|
||
$table->addColumn('preferredName', __('Preferred Name')); | ||
|
||
$table->addColumn('email', __('Email')); | ||
|
||
$table->addActionColumn() | ||
->addParam('gibbonMessengerMailingListID') | ||
->format(function ($mailingList, $actions) { | ||
$actions->addAction('edit', __('Edit')) | ||
->setURL('/modules/Messenger/mailingList_manage_edit.php'); | ||
|
||
$actions->addAction('delete', __('Delete')) | ||
->setURL('/modules/Messenger/mailingList_manage_delete.php'); | ||
}); | ||
|
||
echo $table->render($mailingLists); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/* | ||
Gibbon: the flexible, open school platform | ||
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/) | ||
Copyright © 2010, Gibbon Foundation | ||
Gibbon™, Gibbon Education Ltd. (Hong Kong) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use Gibbon\Forms\Form; | ||
|
||
$page->breadcrumbs | ||
->add(__('Manage Mailing Lists'), 'mailingList_manage.php') | ||
->add(__('Add Recipient')); | ||
|
||
if (isActionAccessible($guid, $connection2, '/modules/Messenger/mailingList_manage_add.php') == false) { | ||
// Access denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
//Proceed! | ||
$editLink = ''; | ||
if (isset($_GET['editID'])) { | ||
$editLink = $session->get('absoluteURL').'/index.php?q=/modules/Messenger/mailingList_manage_edit.php&gibbonMessengerMailingListID='.$_GET['editID']; | ||
} | ||
$page->return->setEditLink($editLink); | ||
|
||
$form = Form::create('mailingList', $session->get('absoluteURL').'/modules/'.$session->get('module').'/mailingList_manage_addProcess.php'); | ||
|
||
$form->addHiddenValue('address', $session->get('address')); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('surname', __('Surname')); | ||
$row->addTextField('surname')->required()->maxLength(60); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('preferredName', __('Preferred Name')); | ||
$row->addTextField('preferredName')->required()->maxLength(60); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('email', __('Email'))->description(__('Must be unique.')); | ||
$row->addEmail('email')->required()->maxLength(75); | ||
|
||
$row = $form->addRow(); | ||
$row->addFooter(); | ||
$row->addSubmit(); | ||
|
||
echo $form->getOutput(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/* | ||
Gibbon: the flexible, open school platform | ||
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/) | ||
Copyright © 2010, Gibbon Foundation | ||
Gibbon™, Gibbon Education Ltd. (Hong Kong) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use Gibbon\Data\Validator; | ||
use Gibbon\Services\Format; | ||
use Gibbon\Domain\Messenger\MailingListGateway; | ||
|
||
require_once '../../gibbon.php'; | ||
|
||
$_POST = $container->get(Validator::class)->sanitize($_POST); | ||
|
||
$URL = $session->get('absoluteURL')."/index.php?q=/modules/Messenger/mailingList_manage_add.php"; | ||
|
||
if (isActionAccessible($guid, $connection2, '/modules/Messenger/mailingList_manage_add.php') == false) { | ||
$URL .= '&return=error0'; | ||
header("Location: {$URL}"); | ||
exit; | ||
} else { | ||
// Proceed! | ||
$mailingListGateway = $container->get(MailingListGateway::class); | ||
|
||
$data = [ | ||
'surname' => $_POST['surname'] ?? '', | ||
'preferredName' => $_POST['preferredName'] ?? '', | ||
'email' => $_POST['email'] ?? '' | ||
]; | ||
|
||
// Validate the required values are present | ||
if (empty($data['surname']) || empty($data['preferredName']) || empty($data['email'])) { | ||
$URL .= '&return=error1'; | ||
header("Location: {$URL}"); | ||
exit; | ||
} | ||
|
||
// Validate that this record is unique | ||
if (!$mailingListGateway->unique($data, ['email'])) { | ||
$URL .= '&return=error7'; | ||
header("Location: {$URL}"); | ||
exit; | ||
} | ||
|
||
// Create the record | ||
$gibbonMessengerMailingListID = $mailingListGateway->insert($data); | ||
|
||
if ($gibbonMessengerMailingListID) { | ||
$URL .= "&return=success0&editID=$gibbonMessengerMailingListID"; | ||
} | ||
else { | ||
$URL .= "&return=error2"; | ||
} | ||
|
||
header("Location: {$URL}"); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/* | ||
Gibbon: the flexible, open school platform | ||
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/) | ||
Copyright © 2010, Gibbon Foundation | ||
Gibbon™, Gibbon Education Ltd. (Hong Kong) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use Gibbon\Forms\Prefab\DeleteForm; | ||
use Gibbon\Domain\Messenger\MailingListGateway; | ||
|
||
if (isActionAccessible($guid, $connection2, '/modules/Messenger/mailingList_manage_delete.php') == false) { | ||
// Access denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
// Proceed! | ||
$gibbonMessengerMailingListID = $_GET['gibbonMessengerMailingListID'] ?? ''; | ||
|
||
if (empty($gibbonMessengerMailingListID)) { | ||
$page->addError(__('You have not specified one or more required parameters.')); | ||
return; | ||
} | ||
|
||
$values = $container->get(MailingListGateway::class)->getByID($gibbonMessengerMailingListID); | ||
|
||
if (empty($values)) { | ||
$page->addError(__('The specified record cannot be found.')); | ||
return; | ||
} | ||
|
||
$form = DeleteForm::createForm($session->get('absoluteURL').'/modules/Messenger/mailingList_manage_deleteProcess.php'); | ||
echo $form->getOutput(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/* | ||
Gibbon: the flexible, open school platform | ||
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/) | ||
Copyright © 2010, Gibbon Foundation | ||
Gibbon™, Gibbon Education Ltd. (Hong Kong) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use Gibbon\Data\Validator; | ||
use Gibbon\Domain\Messenger\MailingListGateway; | ||
|
||
require_once '../../gibbon.php'; | ||
|
||
$_POST = $container->get(Validator::class)->sanitize($_POST); | ||
|
||
$gibbonMessengerMailingListID = $_POST['gibbonMessengerMailingListID'] ?? ''; | ||
|
||
$URL = $session->get('absoluteURL').'/index.php?q=/modules/Messenger/mailingList_manage.php'; | ||
|
||
if (isActionAccessible($guid, $connection2, '/modules/Messenger/mailingList_manage_delete.php') == false) { | ||
$URL .= '&return=error0'; | ||
header("Location: {$URL}"); | ||
exit; | ||
} elseif (empty($gibbonMessengerMailingListID)) { | ||
$URL .= '&return=error1'; | ||
header("Location: {$URL}"); | ||
exit; | ||
} else { | ||
// Proceed! | ||
$mailingListGateway = $container->get(MailingListGateway::class); | ||
$values = $mailingListGateway->getByID($gibbonMessengerMailingListID); | ||
|
||
if (empty($values)) { | ||
$URL .= '&return=error2'; | ||
header("Location: {$URL}"); | ||
exit; | ||
} | ||
|
||
$deleted = $mailingListGateway->delete($gibbonMessengerMailingListID); | ||
|
||
$URL .= !$deleted | ||
? '&return=error2' | ||
: '&return=success0'; | ||
|
||
header("Location: {$URL}"); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/* | ||
Gibbon: the flexible, open school platform | ||
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/) | ||
Copyright © 2010, Gibbon Foundation | ||
Gibbon™, Gibbon Education Ltd. (Hong Kong) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use Gibbon\Forms\Form; | ||
use Gibbon\Domain\Messenger\MailingListGateway; | ||
|
||
if (isActionAccessible($guid, $connection2, '/modules/Messenger/mailingList_manage_edit.php') == false) { | ||
// Access denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
// Proceed! | ||
$gibbonMessengerMailingListID = $_GET['gibbonMessengerMailingListID'] ?? ''; | ||
|
||
$page->breadcrumbs | ||
->add(__m('Manage Mailing List'), 'mailingList_manage.php') | ||
->add(__m('Edit Recipient')); | ||
|
||
if (empty($gibbonMessengerMailingListID)) { | ||
$page->addError(__('You have not specified one or more required parameters.')); | ||
return; | ||
} | ||
|
||
$values = $container->get(MailingListGateway::class)->getByID($gibbonMessengerMailingListID); | ||
|
||
if (empty($values)) { | ||
$page->addError(__('The specified record cannot be found.')); | ||
return; | ||
} | ||
|
||
$form = Form::create('category', $session->get('absoluteURL').'/modules/'.$session->get('module').'/mailingList_manage_editProcess.php'); | ||
|
||
$form->addHiddenValue('address', $session->get('address')); | ||
$form->addHiddenValue('gibbonMessengerMailingListID', $gibbonMessengerMailingListID); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('surname', __('Surname')); | ||
$row->addTextField('surname')->required()->maxLength(60); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('preferredName', __('Preferred Name')); | ||
$row->addTextField('preferredName')->required()->maxLength(60); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('email', __('Email'))->description(__('Must be unique.')); | ||
$row->addEmail('email')->required()->maxLength(75); | ||
|
||
$row = $form->addRow(); | ||
$row->addFooter(); | ||
$row->addSubmit(); | ||
|
||
$form->loadAllValuesFrom($values); | ||
|
||
echo $form->getOutput(); | ||
} |
Oops, something went wrong.