Skip to content

Commit

Permalink
Merge pull request #74 from GibbonEdu/v1.4.00
Browse files Browse the repository at this point in the history
v1.4.20
  • Loading branch information
raynichc authored Feb 24, 2021
2 parents aadcfb3 + 074ef4e commit 19847ee
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 13 deletions.
15 changes: 15 additions & 0 deletions Help Desk/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,18 @@
INSERT INTO `helpDeskDepartmentPermissions` (`departmentPermissionsID`,`departmentID`, `gibbonRoleID`) SELECT NULL, helpDeskDepartments.departmentID, '002' FROM helpDeskDepartments;end
INSERT INTO `helpDeskDepartmentPermissions` (`departmentPermissionsID`,`departmentID`, `gibbonRoleID`) SELECT NULL, helpDeskDepartments.departmentID, '003' FROM helpDeskDepartments;end
";

//v1.4.011
$count++;
$sql[$count][0]="1.4.011";
$sql[$count][1]="
";

//v1.4.20
$count++;
$sql[$count][0]="1.4.20";
$sql[$count][1]="
INSERT INTO `gibbonSetting` (`gibbonSettingID`, `scope`, `name`, `nameDisplay`, `description`, `value`)
VALUES (NULL, 'Help Desk', 'techNotes', 'Technician Notes', 'Whether technicians can leave notes on issues that only other technicians can see.', FALSE);end
CREATE TABLE `helpDeskIssueNotes` (`issueNoteID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, `issueID` int(12) unsigned zerofill NOT NULL, `note` text NOT NULL, `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP, `gibbonPersonID` int(10) unsigned zerofill NOT NULL, PRIMARY KEY (`issueNoteID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;end
";
5 changes: 5 additions & 0 deletions Help Desk/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CHANGELOG
=========

v1.4.20
-------
Added Technician only comments.

v1.4.11
-------
Fixed issues_assignProcess where a bracket was missing
Expand Down
2 changes: 2 additions & 0 deletions Help Desk/helpDesk_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'issueCategory',
'issuePriority',
'issuePriorityName',
'techNotes'
];

$settingGateway = $container->get(SettingGateway::class);
Expand All @@ -60,6 +61,7 @@
->required();
break;
case 'simpleCategories':
case 'techNotes':
$row->addCheckbox($setting['name'])
->checked(intval($setting['value']));
break;
Expand Down
2 changes: 2 additions & 0 deletions Help Desk/helpDesk_settingsProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'issueCategory',
'issuePriority',
'simpleCategories',
'techNotes',
];

$settingGateway = $container->get(SettingGateway::class);
Expand Down Expand Up @@ -70,6 +71,7 @@
}
break;
case 'simpleCategories':
case 'techNotes':
$value = isset($_POST[$setting]) ? '1' : '0';
break;
}
Expand Down
12 changes: 2 additions & 10 deletions Help Desk/issues_assignProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,8 @@
header("Location: {$URL}");
exit();
}

try {
$gibbonModuleID = getModuleIDFromName($connection2, 'Help Desk');
if ($gibbonModuleID == null) {
throw new PDOException('Invalid gibbonModuleID.');
}

if (!$issueGateway->update($issueID, ['technicianID' => $technicianID, 'status' => 'Pending'])) {
throw new PDOException('Could not update issue.');
}
} catch (PDOException $e) {
if (!$issueGateway->update($issueID, ['technicianID' => $technicianID, 'status' => 'Pending'])) {
$URL .= "/issues_assign.php&issueID=$issueID&technicianID=$technicianID&return=error2";
header("Location: {$URL}");
exit();
Expand All @@ -117,6 +108,7 @@
}
}

$gibbonModuleID = getModuleIDFromName($connection2, 'Help Desk');
setLog($connection2, $gibbon->session->get('gibbonSchoolYearID'), $gibbonModuleID, $gibbonPersonID, 'Technician Assigned', ['issueID' => $issueID, 'technicainID' => $technicianID], null);

$URL .= "/issues_discussView.php&issueID=$issueID&return=success0";
Expand Down
104 changes: 104 additions & 0 deletions Help Desk/issues_discussNoteProccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?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\Domain\System\SettingGateway;
use Gibbon\Module\HelpDesk\Domain\IssueGateway;
use Gibbon\Module\HelpDesk\Domain\IssueNoteGateway;
use Gibbon\Module\HelpDesk\Domain\TechGroupGateway;
use Gibbon\Module\HelpDesk\Domain\TechnicianGateway;

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

$URL = $gibbon->session->get('absoluteURL') . '/index.php?q=/modules/' . $gibbon->session->get('module');

if (!isActionAccessible($guid, $connection2, '/modules/Help Desk/issues_view.php')) {
$URL .= '/issues_view.php&return=error0';
header("Location: {$URL}");
exit();
} else {
$issueID = $_POST['issueID'] ?? '';

$issueGateway = $container->get(IssueGateway::class);
$issue = $issueGateway->getByID($issueID);

if (empty($issue)) {
$URL .= '/issues_view.php&return=error1';
header("Location: {$URL}");
exit();
}

$gibbonPersonID = $gibbon->session->get('gibbonPersonID');

$technicianGateway = $container->get(TechnicianGateway::class);
$techGroupGateway = $container->get(TechGroupGateway::class);
$settingGateway = $container->get(SettingGateway::class);

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

if ($technician->isNotEmpty() //Is tech
&& !($gibbonPersonID == $issue['gibbonPersonID']) //Not owner
&& ($issueGateway->isRelated($issueID, $gibbonPersonID) || $techGroupGateway->getPermissionValue($gibbonPersonID, 'fullAccess')) //Has access
&& $settingGateway->getSettingByScope('Help Desk', 'techNotes') //Setting is enabled
) {
//Proceed!
$URL .= "/issues_discussView.php&issueID=$issueID";

$note = $_POST['techNote'] ?? '';

if (empty($note)) {
$URL .= '&return=error1';
header("Location: {$URL}");
exit();
}

try {
$gibbonModuleID = getModuleIDFromName($connection2, 'Help Desk');
if ($gibbonModuleID == null) {
throw new PDOException('Invalid gibbonModuleID.');
}

$issueNoteGateway = $container->get(IssueNoteGateway::class);

$issueNoteID = $issueNoteGateway->insert([
'issueID' => $issueID,
'note' => $note,
'timestamp' => date('Y-m-d H:i:s'),
'gibbonPersonID' => $gibbonPersonID
]);

if ($issueNoteID === false) {
throw new PDOException('Could not insert note.');
}
} catch (PDOException $e) {
$URL .= '&return=error2';
header("Location: {$URL}");
exit();
}

$URL .= '&return=success0';
header("Location: {$URL}");
exit();
} else {
//Fail 0 aka No permission
$URL .= '/issues_view.php&return=error0';
header("Location: {$URL}");
exit();
}
}
?>
44 changes: 44 additions & 0 deletions Help Desk/issues_discussView.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
use Gibbon\Services\Format;
use Gibbon\Module\HelpDesk\Domain\IssueDiscussGateway;
use Gibbon\Module\HelpDesk\Domain\IssueGateway;
use Gibbon\Module\HelpDesk\Domain\IssueNoteGateway;
use Gibbon\Module\HelpDesk\Domain\TechGroupGateway;
use Gibbon\Module\HelpDesk\Domain\TechnicianGateway;
use Gibbon\Domain\DataSet;
use Gibbon\Domain\System\DiscussionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Domain\User\UserGateway;
use Gibbon\Domain\School\FacilityGateway;
use Gibbon\View\View;
Expand Down Expand Up @@ -167,6 +169,48 @@

echo $table->render([$detailsData]);

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

if ($isTechnician && !$isPersonsIssue && $settingGateway->getSettingByScope('Help Desk', 'techNotes')) {
$form = Form::create('techNotes', $gibbon->session->get('absoluteURL') . '/modules/' . $gibbon->session->get('module') . '/issues_discussNoteProccess.php', 'post');
$form->addHiddenValue('issueID', $issueID);
$form->addHiddenValue('address', $gibbon->session->get('address'));

$row = $form->addRow();
$col = $row->addColumn();
$col->addHeading(__('Technician Notes'))->addClass('inline-block');

$col->addWebLink('<img title="'.__('Add Technician Note').'" src="./themes/'.$_SESSION[$guid]['gibbonThemeName'].'/img/plus.png" />')
->addData('toggle', '.techNote')
->addClass('floatRight');

$row = $form->addRow()->setClass('techNote hidden flex flex-col sm:flex-row items-stretch sm:items-center');
$col = $row->addColumn();
$col->addLabel('techNote', __('Technician Note'));
$col->addEditor('techNote', $guid)
->setRows(5)
->showMedia()
->required();

$row = $form->addRow()->setClass('techNote hidden flex flex-col sm:flex-row items-stretch sm:items-center');;
$row->addFooter();
$row->addSubmit();

$issueNoteGateway = $container->get(IssueNoteGateway::class);
$notes = $issueNoteGateway->getIssueNotesByID($issueID)->fetchAll();

if (count($notes) > 0) {
$form->addRow()
->addContent('comments')
->setContent($page->fetchFromTemplate('ui/discussion.twig.html', [
'title' => __(''),
'discussion' => $notes
]));
}

echo $form->getOutput();
}


$form = Form::create('issueDiscuss', $gibbon->session->get('absoluteURL') . '/modules/' . $gibbon->session->get('module') . '/issues_discussPostProccess.php?issueID=' . $issueID, 'post');
$form->addHiddenValue('address', $gibbon->session->get('address'));
Expand Down
15 changes: 13 additions & 2 deletions Help Desk/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$entryURL="issues_view.php";
$type="Additional";
$category="Other";
$version="1.4.11";
$version="1.4.20";
$author="Ray Clark, Ashton Power & Adrien Tremblay";
$url="https://github.com/GibbonEdu/module-helpDesk";

Expand Down Expand Up @@ -56,6 +56,16 @@
PRIMARY KEY (`issueDiscussID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";

$moduleTables[$tables++]="CREATE TABLE `helpDeskIssueNotes` (
`issueNoteID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT,
`issueID` int(12) unsigned zerofill NOT NULL,
`note` text NOT NULL,
`timestamp` timestamp DEFAULT CURRENT_TIMESTAMP,
`gibbonPersonID` int(10) unsigned zerofill NOT NULL,
PRIMARY KEY (`issueNoteID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";


$moduleTables[$tables++]="CREATE TABLE `helpDeskTechnicians` (
`technicianID` int(4) unsigned zerofill NOT NULL AUTO_INCREMENT,
`gibbonPersonID` int(10) unsigned zerofill NOT NULL,
Expand Down Expand Up @@ -110,7 +120,8 @@
(NULL, 'Help Desk', 'issuePriority', 'Issue Priority', 'Different priority levels for the issues.', ''),
(NULL, 'Help Desk', 'issuePriorityName', 'Issue Priority Name', 'Different name for the Issue Priority', 'Priority'),
(NULL, 'Help Desk', 'issueCategory', 'Issue Category', 'Different categories for the issues.', 'Network,Hardware,Software,Application'),
(NULL, 'Help Desk', 'simpleCategories', 'Simple Categories', 'Whether to use Simple Categories or Not.', TRUE)";
(NULL, 'Help Desk', 'simpleCategories', 'Simple Categories', 'Whether to use Simple Categories or Not.', TRUE),
(NULL, 'Help Desk', 'techNotes', 'Technician Notes', 'Whether technicians can leave notes on issues that only other technicians can see.', FALSE)";

//Action rows
//One array per action
Expand Down
35 changes: 35 additions & 0 deletions Help Desk/src/Domain/IssueNoteGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace Gibbon\Module\HelpDesk\Domain;

use Gibbon\Domain\Traits\TableAware;
use Gibbon\Domain\QueryCriteria;
use Gibbon\Domain\QueryableGateway;

/**
* Issue Note Gateway
*
* @version v22
* @since v22
*/
class IssueNoteGateway extends QueryableGateway
{
use TableAware;

private static $tableName = 'helpDeskIssueNotes';
private static $primaryKey = 'issueNoteID';
private static $searchableColumns = [];

public function getIssueNotesByID($issueID) {
$query = $this
->newSelect()
->cols(['helpDeskIssueNotes.note as comment', 'helpDeskIssueNotes.timestamp', 'helpDeskIssueNotes.gibbonPersonID', 'gibbonPerson.title', 'gibbonPerson.surname', 'gibbonPerson.preferredName', 'gibbonPerson.image_240', 'gibbonPerson.username', 'gibbonPerson.email', '"Commented " AS action'])
->from('helpDeskIssueNotes')
->innerJoin('gibbonPerson', 'helpDeskIssueNotes.gibbonPersonID=gibbonPerson.gibbonPersonID')
->where('helpDeskIssueNotes.issueID = :issueID')
->bindValue('issueID', $issueID);

$result = $this->runSelect($query);

return $result;
}
}
2 changes: 1 addition & 1 deletion Help Desk/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
/**
* Sets version information
*/
$moduleVersion='1.4.11';
$moduleVersion='1.4.20';

?>

0 comments on commit 19847ee

Please sign in to comment.