Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Gibbon\Contracts\Comms\Mailer;
use Gibbon\Data\PasswordPolicy;
use Gibbon\Domain\Students\MedicalGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\AlertLevelGateway;
use Gibbon\Domain\System\LogGateway;
use Gibbon\Domain\System\SettingGateway;
Expand Down Expand Up @@ -362,8 +363,7 @@ function getPasswordPolicy($guid, $connection2)

function getFastFinder($connection2, $guid)
{
global $session;

global $session, $container;
$form = Form::create('fastFinder', Url::fromHandlerRoute('indexFindRedirect.php'), 'get');
$form->setClass('blank fullWidth');

Expand All @@ -382,7 +382,7 @@ function getFastFinder($connection2, $guid)
->addValidation('Validate.Presence', 'failureMessage: " "')
->append('<input type="submit" style="height:34px;padding:0 1rem;" value="'.__('Go').'">');

$highestActionClass = getHighestGroupedAction($guid, '/modules/Planner/planner.php', $connection2);
$highestActionClass = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Planner/planner.php');

$templateData = [
'roleCategory' => $session->get('gibbonRoleIDCurrentCategory'),
Expand Down Expand Up @@ -784,7 +784,22 @@ function getHighestMedicalRisk($guid, $gibbonPersonID, $connection2)
return $output;
}

//Looks at the grouped actions accessible to the user in the current module and returns the highest
/**
* Looks at the grouped actions accessible to the user in the current
* module and returns the highest.
*
* @deprecated v25
* Use ActionGateway::getHighestGrouped instead.
*
* @since v12
* @version v23
*
* @param string $guid
* @param string $address
* @param \PDO $connection2
*
* @return string|false
*/
function getHighestGroupedAction($guid, $address, $connection2)
{
global $session;
Expand Down Expand Up @@ -925,7 +940,8 @@ function getAlertBar($guid, $connection2, $gibbonPersonID, $privacy = '', $divEx

$target = ($target == "_blank") ? "_blank" : "_self";

$highestAction = getHighestGroupedAction($guid, '/modules/Students/student_view_details.php', $connection2);
/** @var string|false */
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Students/student_view_details.php');
if ($highestAction == 'View Student Profile_full' or $highestAction == 'View Student Profile_fullNoNotes' or $highestAction == 'View Student Profile_fullEditAllNotes') {
// Individual Needs
$dataAlert = array('gibbonPersonID' => $gibbonPersonID);
Expand Down
17 changes: 10 additions & 7 deletions index_fastFinder_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@
// Cancel out early for empty searches
if (empty($searchTerm)) die('[]');

/** @var ActionGateway */
$actionGateway = $container->get(ActionGateway::class);

// Check access levels
$studentIsAccessible = isActionAccessible($guid, $connection2, '/modules/students/student_view.php');
$highestActionStudent = getHighestGroupedAction($guid, '/modules/students/student_view.php', $connection2);
$highestActionStudent = $actionGateway->getHighestGrouped('/modules/students/student_view.php');

$staffIsAccessible = isActionAccessible($guid, $connection2, '/modules/Staff/staff_view.php');
$classIsAccessible = false;
$alarmIsAccessible = isActionAccessible($guid, $connection2, '/modules/System Admin/alarm.php');
$highestActionClass = getHighestGroupedAction($guid, '/modules/Planner/planner.php', $connection2);
$highestActionClass = $actionGateway->getHighestGrouped('/modules/Planner/planner.php');
if (isActionAccessible($guid, $connection2, '/modules/Planner/planner.php') and $highestActionClass != 'Lesson Planner_viewMyChildrensClasses') {
$classIsAccessible = true;
}
Expand All @@ -62,7 +65,7 @@
} else {
$actions = $session->get('fastFinderActions');
}

if (!empty($actions) && is_array($actions)) {
foreach ($actions as $action) {
// Add actions that match the search query to the result set
Expand Down Expand Up @@ -147,12 +150,12 @@
WHEN gibbonPerson.studentID LIKE :search THEN concat(surname, ', ', preferredName, ' (', gibbonFormGroup.name, ', ', gibbonPerson.studentID, ')')
WHEN gibbonPerson.firstName LIKE :search AND firstName<>preferredName THEN concat(surname, ', ', firstName, ' \"', preferredName, '\" (', gibbonFormGroup.name, ')' )
ELSE concat(surname, ', ', preferredName, ' (', gibbonFormGroup.name, ')') END) AS name,
NULL as type
NULL as type
FROM gibbonPerson, gibbonStudentEnrolment, gibbonFormGroup, gibbonFamilyChild, gibbonFamilyAdult
WHERE gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID
AND gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID
AND gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID
AND gibbonFamilyAdult.gibbonPersonID=:gibbonPersonID
AND gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID
AND gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID
AND gibbonFamilyChild.gibbonFamilyID=gibbonFamilyAdult.gibbonFamilyID";
}
// Allow individuals to only search themselves
Expand All @@ -166,7 +169,7 @@
NULL as type
FROM gibbonPerson, gibbonStudentEnrolment, gibbonFormGroup
WHERE gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID
AND gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID
AND gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID
AND gibbonPerson.gibbonPersonID=:gibbonPersonID";
}
// Allow searching of all students
Expand Down
5 changes: 3 additions & 2 deletions modules/Activities/activities_attendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Domain\System\ActionGateway;
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
use Gibbon\Domain\Attendance\AttendanceLogPersonGateway;
Expand All @@ -38,7 +39,7 @@
echo __('Choose Activity');
echo '</h2>';

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_attendance.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_attendance.php');
$gibbonActivityID = null;
if (isset($_GET['gibbonActivityID'])) {
$gibbonActivityID = $_GET['gibbonActivityID'];
Expand Down Expand Up @@ -185,7 +186,7 @@

$form->addHiddenValue('address', $session->get('address'));
$form->addHiddenValue('gibbonPersonID', $session->get('gibbonPersonID'));

if (isActionAccessible($guid, $connection2, '/modules/Activities/report_attendanceExport.php')) {
$form->addHeaderAction('download', __('Export to Excel'))
->setURL('/modules/Activities/report_attendanceExport.php')
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_attendanceProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Gibbon\Data\Validator;
use Gibbon\Domain\System\ActionGateway;

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

Expand All @@ -36,7 +37,7 @@

$gibbonPersonID = $_POST['gibbonPersonID'] ?? '';

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_attendance.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_attendance.php');

if($highestAction == "Enter Activity Attendance_leader") {
try {
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_manage_enrolment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
Expand All @@ -35,7 +36,7 @@
//Proceed!
$gibbonActivityID = (isset($_GET['gibbonActivityID']))? $_GET['gibbonActivityID'] : null;

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_manage_enrolment.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_manage_enrolment.php');
if ($highestAction == 'My Activities_viewEditEnrolment') {

$data = array('gibbonPersonID' => $gibbon->session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $gibbon->session->get('gibbonSchoolYearID'), 'gibbonActivityID' => $gibbonActivityID);
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_manage_enrolment_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
Expand All @@ -34,7 +35,7 @@
//Proceed!
$gibbonActivityID = (isset($_GET['gibbonActivityID']))? $_GET['gibbonActivityID'] : null;

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_manage_enrolment.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_manage_enrolment.php');
if ($highestAction == 'My Activities_viewEditEnrolment') {
$data = array('gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'), 'gibbonActivityID' => $gibbonActivityID);
$sql = "SELECT gibbonActivity.*, NULL as status, gibbonActivityStaff.role FROM gibbonActivity JOIN gibbonActivityStaff ON (gibbonActivity.gibbonActivityID=gibbonActivityStaff.gibbonActivityID) WHERE gibbonActivity.gibbonActivityID=:gibbonActivityID AND gibbonActivityStaff.gibbonPersonID=:gibbonPersonID AND gibbonActivityStaff.role='Organiser' AND gibbonSchoolYearID=:gibbonSchoolYearID AND active='Y' ORDER BY name";
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_manage_enrolment_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Domain\System\ActionGateway;
use Gibbon\Forms\Prefab\DeleteForm;

if (isActionAccessible($guid, $connection2, '/modules/Activities/activities_manage_enrolment_delete.php') == false) {
Expand All @@ -28,7 +29,7 @@
//Proceed!
$gibbonActivityID = (isset($_GET['gibbonActivityID']))? $_GET['gibbonActivityID'] : null;

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_manage_enrolment.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_manage_enrolment.php');
if ($highestAction == 'My Activities_viewEditEnrolment') {


Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_manage_enrolment_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
Expand All @@ -34,7 +35,7 @@
//Proceed!
$gibbonActivityID = (isset($_GET['gibbonActivityID']))? $_GET['gibbonActivityID'] : null;

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_manage_enrolment.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_manage_enrolment.php');
if ($highestAction == 'My Activities_viewEditEnrolment') {


Expand Down
9 changes: 5 additions & 4 deletions modules/Activities/activities_my.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Gibbon\Services\Format;
use Gibbon\Tables\DataTable;
use Gibbon\Domain\Activities\ActivityGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;

//Module includes
Expand All @@ -31,13 +32,13 @@
// Access denied
$page->addError(__('You do not have access to this action.'));
} else {
$page->breadcrumbs->add(__('My Activities'));
$page->breadcrumbs->add(__('My Activities'));

$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_attendance.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_attendance.php');
$canAccessEnrolment = isActionAccessible($guid, $connection2, '/modules/Activities/activities_manage_enrolment.php');

$activityGateway = $container->get(ActivityGateway::class);

// CRITERIA
$criteria = $activityGateway->newQueryCriteria()
->sortBy('name')
Expand Down Expand Up @@ -77,7 +78,7 @@
->isModal(1000, 550)
->setURL('/modules/Activities/activities_my_full.php');

if ($highestAction == "Enter Activity Attendance" ||
if ($highestAction == "Enter Activity Attendance" ||
($highestAction == "Enter Activity Attendance_leader" && ($activity['role'] == 'Organiser' || $activity['role'] == 'Assistant' || $activity['role'] == 'Coach'))) {
$actions->addAction('attendance', __('Attendance'))
->setIcon('attendance')
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_my_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Services\Format;

Expand All @@ -33,7 +34,7 @@
echo '</div>';
} else {
//Get action with highest precendence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped($_GET['q']);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Gibbon\Services\Format;
use Gibbon\Domain\Activities\ActivityGateway;
use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Domain\System\ActionGateway;

//Module includes
require_once __DIR__ . '/moduleFunctions.php';
Expand All @@ -34,7 +35,7 @@
$page->addError(__('You do not have access to this action.'));
} else {
// Get action with highest precedence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped($_GET['q']);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_view_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Services\Format;

Expand All @@ -33,7 +34,7 @@
echo '</div>';
} else {
//Get action with highest precendence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped($_GET['q']);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_view_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Gibbon\Domain\Activities\ActivityGateway;
use Gibbon\Domain\School\SchoolYearTermGateway;
use Gibbon\Services\Format;
use Gibbon\Domain\System\ActionGateway;

//Module includes
require_once __DIR__ . '/moduleFunctions.php';
Expand All @@ -34,7 +35,7 @@
$page->addError(__('You do not have access to this action.'));
} else {
//Get action with highest precendence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped($_GET['q']);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
3 changes: 2 additions & 1 deletion modules/Activities/activities_view_registerProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Gibbon\Services\Format;
use Gibbon\Domain\Activities\ActivityGateway;
use Gibbon\Data\Validator;
use Gibbon\Domain\System\ActionGateway;

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

Expand All @@ -47,7 +48,7 @@
header("Location: {$URL}");
exit;
} else {
$highestAction = getHighestGroupedAction($guid, '/modules/Activities/activities_view_register.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Activities/activities_view_register.php');
if ($highestAction == false) {
$URL .= '&return=error0';
header("Location: {$URL}");
Expand Down
3 changes: 2 additions & 1 deletion modules/Attendance/attendance_take_byFormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Domain\System\ActionGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;
use Gibbon\Forms\DatabaseFormFactory;
Expand All @@ -36,7 +37,7 @@
// Access denied
$page->addError(__('You do not have access to this action.'));
} else {
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped($_GET['q']);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
3 changes: 2 additions & 1 deletion modules/Attendance/attendance_take_byFormGroupProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Gibbon\Services\Format;
use Gibbon\Module\Attendance\AttendanceView;
use Gibbon\Domain\Attendance\AttendanceLogPersonGateway;
use Gibbon\Domain\System\ActionGateway;

//Gibbon system-wide includes
require __DIR__ . '/../../gibbon.php';
Expand All @@ -39,7 +40,7 @@
$URL .= '&return=error0';
header("Location: {$URL}");
} else {
$highestAction = getHighestGroupedAction($guid, '/modules/Attendance/attendance_take_byFormGroup.php', $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped('/modules/Attendance/attendance_take_byFormGroup.php');
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
3 changes: 2 additions & 1 deletion modules/Attendance/report_studentHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Gibbon\Forms\Form;
use Gibbon\Domain\DataSet;
use Gibbon\Domain\System\ActionGateway;
use Gibbon\Services\Format;
use Gibbon\Tables\DataTable;
use Gibbon\Forms\DatabaseFormFactory;
Expand All @@ -39,7 +40,7 @@
$page->scripts->add('chart');

//Get action with highest precendence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
$highestAction = $container->get(ActionGateway::class)->getHighestGrouped($_GET['q']);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
Expand Down
Loading