Skip to content

Commit

Permalink
Merge pull request #86 from raynichc/main
Browse files Browse the repository at this point in the history
Setting Manager, manifest clean up and tech note fix
  • Loading branch information
raynichc authored Oct 17, 2021
2 parents 8670512 + de30b56 commit a3b9b04
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 242 deletions.
1 change: 1 addition & 0 deletions Help Desk/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
$sql[$count][1]="
";

//v2.1.00
$count++;
$sql[$count][0]="2.1.00";
$sql[$count][1]="
Expand Down
2 changes: 2 additions & 0 deletions Help Desk/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ CHANGELOG
v2.1.00
-------
Introduced reply templates.
Implemented Setting Manager
Fixed tech note permission checking.

v2.0.02
-------
Expand Down
43 changes: 4 additions & 39 deletions Help Desk/helpDesk_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;

require_once __DIR__ . '/moduleFunctions.php';

$page->breadcrumbs->add(__('Manage Help Desk Settings'));

Expand All @@ -27,47 +28,11 @@
$page->addError(__('You do not have access to this action.'));
} else {
//Proceed!
//I do this to control the order, there is probably another way, until then, too bad!
$settings = [
'simpleCategories',
'issueCategory',
'issuePriority',
'issuePriorityName',
'techNotes'
];

$settingGateway = $container->get(SettingGateway::class);
$settingManager = getSettings($container);

$form = Form::create('helpDeskSettings', $session->get('absoluteURL') . '/modules/' . $session->get('module') . '/helpDesk_settingsProcess.php');
$form = $settingManager->form($session->get('absoluteURL') . '/modules/' . $session->get('module') . '/helpDesk_settingsProcess.php');
$form->addHiddenValue('address', $session->get('address'));

foreach ($settings as $settingName) {
$setting = $settingGateway->getSettingByScope('Help Desk', $settingName, true);
$row = $form->addRow();
$row->addLabel($setting['name'], __($setting['nameDisplay']))->description($setting['description']);
switch ($settingName) {
case 'issueCategory':
case 'issuePriority':
$row->addTextArea($setting['name'])
->setValue($setting['value']);
break;
case 'issuePriorityName':
$row->addTextField($setting['name'])
->setValue($setting['value'])
->required();
break;
case 'simpleCategories':
case 'techNotes':
$row->addCheckbox($setting['name'])
->checked(intval($setting['value']));
break;
}
}

$row = $form->addRow();
$row->addFooter();
$row->addSubmit();

echo $form->getOutput();
}
?>
53 changes: 2 additions & 51 deletions Help Desk/helpDesk_settingsProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

use Gibbon\Domain\System\LogGateway;
use Gibbon\Domain\System\SettingGateway;

require_once '../../gibbon.php';

Expand All @@ -34,60 +33,12 @@
} else {
$URL .= '/helpDesk_settings.php';

//Not a fan, but too bad!
$settings = [
'resolvedIssuePrivacy',
'issuePriorityName',
'issueCategory',
'issuePriority',
'simpleCategories',
'techNotes',
];

$settingGateway = $container->get(SettingGateway::class);

$dbFail = false;

//Is this really better, potentially, but I'm not going to worry about it too much.
foreach ($settings as $setting) {
if (isset($_POST[$setting]) || $setting == 'simpleCategories') {
$value = '';
switch ($setting) {
case 'issueCategory':
case 'issuePriority':
$value = implode(',', explodeTrim($_POST[$setting]));
break;
case 'resolvedIssuePrivacy':
if (!in_array($_POST[$setting], privacyOptions())) {
$URL .= '&return=error1';
header("Location: {$URL}");
exit();
}
case 'issuePriorityName':
$value = $_POST[$setting];
if (empty($value)) {
$URL .= '&return=error1';
header("Location: {$URL}");
exit();
}
break;
case 'simpleCategories':
case 'techNotes':
$value = isset($_POST[$setting]) ? '1' : '0';
break;
}
$dbFail |= !$settingGateway->updateSettingByScope('Help Desk', $setting, $value);
}
}
$settingManager = getSettings($container);
$return = $settingManager->process($_POST);

$logGateway = $container->get(LogGateway::class);
$logGateway->addLog($session->get('gibbonSchoolYearID'), 'Help Desk', $session->get('gibbonPersonID'), 'Help Desk Settings Edited');

$return = 'success0';
if ($dbFail) {
$return = 'warning1';
}

$URL .= "&return=$return";
header("Location: {$URL}");
exit();
Expand Down
4 changes: 3 additions & 1 deletion Help Desk/issues_discussNoteProccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@

$technician = $technicianGateway->getTechnicianByPersonID($gibbonPersonID);

$noTech = empty($technicianGateway->getByID($issue['technicianID']));

if ($technician->isNotEmpty() //Is tech
&& !($gibbonPersonID == $issue['gibbonPersonID']) //Not owner
&& ($issueGateway->isRelated($issueID, $gibbonPersonID) || $techGroupGateway->getPermissionValue($gibbonPersonID, 'fullAccess')) //Has access
&& ($noTech || $issueGateway->isRelated($issueID, $gibbonPersonID) || $techGroupGateway->getPermissionValue($gibbonPersonID, 'fullAccess')) //Has access (no tech assigned, or is related, or has full acces) TODO: No Tech Check should probably check that the tech has permission to view unassigned issues.
&& $settingGateway->getSettingByScope('Help Desk', 'techNotes') //Setting is enabled
) {
//Proceed!
Expand Down
Loading

0 comments on commit a3b9b04

Please sign in to comment.