Linux cesa-www-main 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
Apache/2.4.68 (Debian)
Server IP : 10.218.0.2 & Your IP : 216.73.217.117
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
v3.cesa.co.za /
src /
UserBundle /
Util /
Delete
Unzip
Name
Size
Permission
Date
Action
CCEStudentDisplayOrder.php
2.97
KB
-rw-r--r--
2026-05-26 09:32
Save
Rename
<?php namespace App\UserBundle\Util; use Doctrine\ORM\QueryBuilder; /** * Standard CCEStudent list ordering: KnownAs, else FirstName, then Surname. */ final class CCEStudentDisplayOrder { public static function sqlOrderByDisplayName(string $tableAlias = 'CCEStudents'): string { $alias = preg_replace('/[^A-Za-z0-9_]/', '', $tableAlias); if ($alias === '') { $alias = 'CCEStudents'; } return 'CASE WHEN ' . $alias . '.KnownAs IS NULL OR TRIM(' . $alias . '.KnownAs) = \'\'' . ' THEN ' . $alias . '.FirstName ELSE ' . $alias . '.KnownAs END, ' . $alias . '.Surname'; } public static function applyToQueryBuilder(QueryBuilder $qb, string $alias = 's'): void { $qb->addSelect( 'CASE WHEN ' . $alias . '.known_as IS NULL OR TRIM(' . $alias . '.known_as) = \'\'' . ' THEN ' . $alias . '.first_name ELSE ' . $alias . '.known_as END AS HIDDEN _studentSortPrimary' ); $qb->addOrderBy('_studentSortPrimary', 'ASC'); $qb->addOrderBy($alias . '.surname', 'ASC'); } /** * @param object $left * @param object $right */ public static function compareObjects($left, $right): int { $cmp = strcasecmp(self::getObjectSortPrimaryName($left), self::getObjectSortPrimaryName($right)); if ($cmp !== 0) { return $cmp; } return strcasecmp(self::getObjectSortSurname($left), self::getObjectSortSurname($right)); } /** * @param array<int, array<string, mixed>> $rows */ public static function sortRowsWithStudentObject(array &$rows, string $studentKey = 'student'): void { if (count($rows) <= 1) { return; } usort( $rows, static function (array $left, array $right) use ($studentKey): int { $studentLeft = $left[$studentKey] ?? null; $studentRight = $right[$studentKey] ?? null; if (!is_object($studentLeft) || !is_object($studentRight)) { return 0; } return self::compareObjects($studentLeft, $studentRight); } ); } /** * @param object $object */ public static function getObjectSortPrimaryName($object): string { if (is_object($object) && method_exists($object, 'getKnownAs')) { $knownAs = trim((string) $object->getKnownAs()); if ($knownAs !== '') { return $knownAs; } } if (is_object($object) && method_exists($object, 'getFirstName')) { return trim((string) $object->getFirstName()); } return ''; } /** * @param object $object */ public static function getObjectSortSurname($object): string { if (is_object($object) && method_exists($object, 'getSurname')) { return trim((string) $object->getSurname()); } return ''; } }