public function viewContact($flag = true) { if (!session_id()) { session_start(); } $id = false; if (isset($_SESSION['identityId'])) { $id = $_SESSION['identityId']; } else { if (isset($_GET['id'])) { $id = $_GET['id']; } else { $_SESSION['Error'] = "You can't view student contacts without having an ID."; } } if ($id) { require_once 'models/student.php'; require_once 'models/studentContact.php'; require_once 'models/identity.php'; require_once 'models/address.php'; require_once 'models/phone.php'; // Get identity of contact $identity = Identity::findById($id); $identity = $identity->getValues(); $type = ['label' => 'Contact', 'id' => $id]; // Get addresses belonging to identity $addresses = []; foreach (Address::findByIdentityId($id) as $i) { $addresses[] = $i->getValues(); } $phoneNumbers = []; foreach (Phone::findByIdentityId($id) as $i) { $phoneNumbers[] = $i->getValues(); } // Load Contact $students = []; foreach (StudentContact::findByIdentityId($id)->getValues()['relationships'] as $i) { $students[] = array('relationship' => $i['type'], 'student' => Student::findById($i['studentID'])->getValues()); } if ($flag) { // This individual is a contact for: student identity, relationship type, edit controls require_once 'views/contact/edit.php'; } } }