/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $input = $_REQUEST['inputData']; $portal = $_REQUEST['portalId']; $groupId = $_REQUEST['groupId']; // Retrieve other important values and objects $username = \Current_User::getUsername(); $portalObjs = \AppSync\PortalFactory::getPortalById($portal); $umbrellaId = $portalObjs[0]->getUmbrellaId(); $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId); // If the permissions array is empty then the user does not have permission to use this command // throw an error back to the front end. if (sizeof($permissions) == 0) { echo json_encode(array('status' => 0, 'message' => 'You do not have permission to add students to this group.')); exit; } // If the input is not a number then it must be a username, retrieve the banner if (!is_numeric($input)) { //Banner $banner = \AppSync\UtilityFunctions::getBannerIDFromEmail($input); if ($banner === false) { echo json_encode(array('status' => 0)); exit; } } else { $banner = $input; } // Retrieve the student and make sure it is not null, passing an error // back to the front end if it is $student = \AppSync\UtilityFunctions::getStudentByBanner($banner); if ($student === false) { $returnData = array('status' => 0); echo json_encode($returnData); exit; } // Pass the student info and group id to the function responsible for interacting // with the OrgSync API $status = $this->removeGroupAccount($student->{'emailAddress'}, $groupId); // Create the response to the front end $name = $student->{'firstName'} . ' ' . $student->{'lastName'}; if ($status) { $returnData = array('status' => 1, 'name' => $name); } else { $returnData = array('status' => 2, 'name' => $name); } // Echo the values back to the front end after encoding them. echo json_encode($returnData); exit; }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $portal = $_REQUEST['org_id']; // Retrieve other important values and objects $username = \Current_User::getUsername(); $portalObjs = \AppSync\PortalFactory::getPortalById($portal); $umbrellaId = $portalObjs[0]->getUmbrellaId(); $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId); // If the permissions array is empty then the user does not have permission to use this command // throw an error back to the front end. if (sizeof($permissions) == 0) { echo '<div style="display: none;">User does not have permission to access this data.</div>'; exit; } // Attempt to retrieve the portal members, echoing the error message back if there is an exception try { $portalMembers = $this->getOrgMembers($_REQUEST['org_id']); echo json_encode($portalMembers); } catch (\Exception $e) { echo '<div style="display: none;">' . $e->getMessage() . '</div>'; } exit; }