-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from powertashton/master
Helpdesk Reply Templates
- Loading branch information
Showing
17 changed files
with
711 additions
and
199 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/* | ||
Gibbon, Flexible & Open School System | ||
Copyright (C) 2010, Ross Parker | ||
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(__('Reply Templates'), 'helpDesk_manageReplyTemplates.php') | ||
->add(__('Add Template')); | ||
|
||
if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
//Acess denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
if(isset($_GET['helpDeskReplyTemplateID'])) { | ||
$page->return->setEditLink($session->get('absoluteURL') . '/index.php?q=/modules/' . $session->get('module') . '/helpDesk_editReplyTemplate.php&helpDeskReplyTemplateID=' . $_GET['helpDeskReplyTemplateID']); | ||
} | ||
|
||
$form = Form::create('addReplyTemplate', $session->get('absoluteURL') . '/modules/' . $session->get('module') . '/helpDesk_addReplyTemplateProcess.php'); | ||
$form->addHiddenValue('address', $session->get('address')); | ||
$form->setTitle('Add Reply Template'); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('name', 'Name'); | ||
$row->addTextfield('name') | ||
->setRequired(true) | ||
->maxLength(30) | ||
->uniqueField('./modules/' . $session->get('module') . '/helpDesk_addReplyTemplateAjax.php'); | ||
|
||
$row = $form->addRow(); | ||
$column = $row->addColumn(); | ||
$column->addLabel('body', 'Body'); | ||
$column->addEditor('body', $guid) | ||
->showMedia() | ||
->setRequired(true); | ||
|
||
$row = $form->addRow(); | ||
$row->addFooter(); | ||
$row->addSubmit(); | ||
|
||
print $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,41 @@ | ||
<?php | ||
/* | ||
Gibbon, Flexible & Open School System | ||
Copyright (C) 2010, Ross Parker | ||
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/>. | ||
*/ | ||
|
||
require_once '../../gibbon.php'; | ||
|
||
if (!$session->has('gibbonPersonID') || !$session->has('gibbonRoleIDPrimary') | ||
|| !isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
die(__('Your request failed because you do not have access to this action.')); | ||
} else { | ||
$currentTemplateName = $_POST['currentTemplateName'] ?? null; | ||
$templateName = $_POST['name'] ?? ''; | ||
|
||
if ($currentTemplateName != null && $currentTemplateName == $templateName) { | ||
echo 0; | ||
die(); | ||
} | ||
|
||
$data = array('name' => $templateName); | ||
$sql = 'SELECT COUNT(*) FROM helpDeskReplyTemplate WHERE name=:name'; | ||
$result = $pdo->executeQuery($data, $sql); | ||
|
||
echo ($result && $result->rowCount() == 1)? $result->fetchColumn(0) : -1; | ||
} | ||
|
||
?> |
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,41 @@ | ||
<?php | ||
|
||
use Gibbon\Module\HelpDesk\Domain\ReplyTemplateGateway; | ||
|
||
require_once '../../gibbon.php'; | ||
|
||
$URL = $session->get('absoluteURL') . '/index.php?q=/modules/' . $session->get('module'); | ||
|
||
if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
//Acess denied | ||
$URL .= '/issues_view.php&return=error0'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
$URL .= '/helpDesk_manageReplyTemplates.php'; | ||
|
||
$replyTemplateGateway = $container->get(ReplyTemplateGateway::class); | ||
|
||
$data = [ | ||
'name' => $_POST['name'] ?? '', | ||
'body' => $_POST['body'] ?? '', | ||
]; | ||
|
||
if (empty($data['name']) || empty($data['body']) || !$replyTemplateGateway->unique($data, ['name'])) { | ||
$URL .= '&return=error1'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
$helpDeskReplyTemplateID = $replyTemplateGateway->insert($data); | ||
|
||
if ($helpDeskReplyTemplateID === false) { | ||
$URL .= '&return=error2'; | ||
} else { | ||
$URL .= '&return=success0&helpDeskReplyTemplateID=' . $helpDeskReplyTemplateID; | ||
} | ||
|
||
header("Location: {$URL}"); | ||
exit(); | ||
} | ||
} | ||
?> |
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,41 @@ | ||
<?php | ||
/* | ||
Gibbon, Flexible & Open School System | ||
Copyright (C) 2010, Ross Parker | ||
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\Module\HelpDesk\Domain\ReplyTemplateGateway; | ||
|
||
if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
//Acess denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
$replyTemplateGateway = $container->get(ReplyTemplateGateway::class); | ||
|
||
$helpDeskReplyTemplateID = $_GET['helpDeskReplyTemplateID'] ?? ''; | ||
|
||
if (empty($helpDeskReplyTemplateID) || !$replyTemplateGateway->exists($helpDeskReplyTemplateID)) { | ||
$page->addError(__('Invalid Template.')); | ||
} else { | ||
$form = DeleteForm::createForm($session->get('absoluteURL') . '/modules/' . $session->get('module') . "/helpDesk_deleteReplyTemplateProcess.php"); | ||
$form->addHiddenValue('address', $session->get('address')); | ||
$form->addHiddenValue('helpDeskReplyTemplateID', $helpDeskReplyTemplateID); | ||
|
||
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,36 @@ | ||
<?php | ||
|
||
use Gibbon\Module\HelpDesk\Domain\ReplyTemplateGateway; | ||
|
||
require_once '../../gibbon.php'; | ||
|
||
$URL = $session->get('absoluteURL') . '/index.php?q=/modules/' . $session->get('module'); | ||
|
||
if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
//Acess denied | ||
$URL .= '/issues_view.php&return=error0'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
$URL .= '/helpDesk_manageReplyTemplates.php'; | ||
|
||
$replyTemplateGateway = $container->get(ReplyTemplateGateway::class); | ||
|
||
$helpDeskReplyTemplateID = $_POST['helpDeskReplyTemplateID'] ?? ''; | ||
|
||
if (empty($helpDeskReplyTemplateID) || !$replyTemplateGateway->exists($helpDeskReplyTemplateID)) { | ||
$URL .= '&return=error1'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
if ($replyTemplateGateway->delete($helpDeskReplyTemplateID)) { | ||
$URL .= '&return=success0'; | ||
} else { | ||
$URL .= '&return=error2'; | ||
} | ||
|
||
header("Location: {$URL}"); | ||
exit(); | ||
} | ||
} | ||
?> |
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, Flexible & Open School System | ||
Copyright (C) 2010, Ross Parker | ||
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\Module\HelpDesk\Domain\ReplyTemplateGateway; | ||
use Gibbon\Forms\Form; | ||
|
||
$page->breadcrumbs | ||
->add(__('Reply Templates'), 'helpDesk_manageReplyTemplates.php') | ||
->add(__('Edit Template')); | ||
|
||
if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
//Acess denied | ||
$page->addError(__('You do not have access to this action.')); | ||
} else { | ||
$replyTemplateGateway = $container->get(ReplyTemplateGateway::class); | ||
|
||
$helpDeskReplyTemplateID = $_GET['helpDeskReplyTemplateID'] ?? ''; | ||
$replyTemplate = $replyTemplateGateway->getByID($helpDeskReplyTemplateID); | ||
|
||
if (empty($replyTemplate)) { | ||
$page->addError(__('Invalid Reply Template.')); | ||
} else { | ||
$form = Form::create('editRiskTemplate', $session->get('absoluteURL') . '/modules/' . $session->get('module') . '/helpDesk_editReplyTemplateProcess.php'); | ||
$form->addHiddenValue('address', $session->get('address')); | ||
$form->addHiddenValue('helpDeskReplyTemplateID', $helpDeskReplyTemplateID); | ||
$form->setTitle('Edit Reply Template'); | ||
|
||
$row = $form->addRow(); | ||
$row->addLabel('name', 'Name'); | ||
$row->addTextfield('name') | ||
->setRequired(true) | ||
->maxLength(30) | ||
->uniqueField('./modules/' . $session->get('module') . '/helpDesk_addReplyTemplateAjax.php', ['currentTemplateName' => $replyTemplate['name']]) | ||
->setValue($replyTemplate['name']); | ||
|
||
$row = $form->addRow(); | ||
$column = $row->addColumn(); | ||
$column->addLabel('body', 'Body'); | ||
$column->addEditor('body', $guid) | ||
->setRequired(true) | ||
->showMedia() | ||
->setValue($replyTemplate['body']); | ||
|
||
$row = $form->addRow(); | ||
$row->addFooter(); | ||
$row->addSubmit(); | ||
|
||
print $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,46 @@ | ||
<?php | ||
|
||
use Gibbon\Module\HelpDesk\Domain\ReplyTemplateGateway; | ||
|
||
require_once '../../gibbon.php'; | ||
|
||
$URL = $session->get('absoluteURL') . '/index.php?q=/modules/' . $session->get('module'); | ||
|
||
if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/helpDesk_manageReplyTemplates.php')) { | ||
//Acess denied | ||
$URL .= '/issues_view.php&return=error0'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
|
||
$replyTemplateGateway = $container->get(ReplyTemplateGateway::class); | ||
|
||
$helpDeskReplyTemplateID = $_POST['helpDeskReplyTemplateID'] ?? ''; | ||
|
||
if (empty($helpDeskReplyTemplateID) || !$replyTemplateGateway->exists($helpDeskReplyTemplateID)) { | ||
$URL .= '/helpDesk_manageReplyTemplates.php&return=error1'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
$URL .= '/helpDesk_editReplyTemplate.php'; | ||
$data = [ | ||
'name' => $_POST['name'] ?? '', | ||
'body' => $_POST['body'] ?? '', | ||
]; | ||
if (empty($data['name']) || empty($data['body']) || !$replyTemplateGateway->unique($data, ['name'], $helpDeskReplyTemplateID)) { | ||
$URL .= '&return=error1'; | ||
header("Location: {$URL}"); | ||
exit(); | ||
} else { | ||
if (!$replyTemplateGateway->update($helpDeskReplyTemplateID, $data)) { | ||
$URL .= '&return=error2'; | ||
} else { | ||
$URL .= '&return=success0&helpDeskReplyTemplateID=' . $helpDeskReplyTemplateID; | ||
} | ||
|
||
header("Location: {$URL}"); | ||
exit(); | ||
} | ||
} | ||
} | ||
?> |
Oops, something went wrong.