/** * The main function for executing the command. */ public function execute() { // Make sure the user has the appropriate permissions to make changes to the permissions settings. // Basically only deities will have access to permissions. if (!\Current_User::isDeity()) { echo json_encode('user does not have permission to retrieve other user information'); exit; } // Retrieve the permissions from the database $permissions = \AppSync\UmbrellaAdminFactory::getAllUmbrellaAdmins(); $userList = array(); $returnData = array(); // For each permission check to see if the username is in the userList array, // if not then add it to the array foreach ($permissions as $permission) { $username = $permission->getUsername(); if (!in_array($username, $userList, true)) { array_push($userList, $username); } } // For each username add it to an associative array to be sent to the front end foreach ($userList as $user) { $node = array('username' => $user); $returnData[] = $node; } echo json_encode($returnData); exit; }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $umbrellaId = $_REQUEST['umbrellaId']; // Retrieve other important values and objects $username = \Current_User::getUsername(); $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 portals and do a fuzzy search of them for the searchString try { $portals = \AppSync\PortalFactory::getPortals(); $searchString = $_REQUEST['searchString']; $umbrella = $_REQUEST['umbrellaId']; $portList = $this->portalFuzzySearch($searchString, $umbrella, $portals); echo $this->encodePortals($portList); } catch (\Exception $e) { echo '<div style="display: none;">' . $e->getMessage() . '</div>'; } exit; }
/** * The main function for executing the command. */ public function execute() { // Make sure the user has the appropriate permissions to make changes to the permissions settings. // Basically only deities will have access to permissions. if (!\Current_User::isDeity()) { echo json_encode("user does not have permission to change permissions"); exit; } // Retrieve the input values from the request $username = $_REQUEST['username']; $umbrellaId = $_REQUEST['umbrella']; // Retrieve the permissions from the database $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId); // If they already have permission to the given umbrella, then do nothing, otherwise // add the permission to their account. if (sizeof($permissions) == 0) { $newAdmin = new \AppSync\UmbrellaAdmin(null, $username, $umbrellaId); \AppSync\UmbrellaAdminFactory::save($newAdmin); echo json_encode("success"); exit; } else { echo json_encode("already exists"); exit; } }
/** * 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() { // Make sure the user has the appropriate permissions to make changes to the permissions settings. // Basically only deities will have access to permissions. if (!\Current_User::isDeity()) { echo json_encode("user does not have permission to change permissions"); exit; } // Retrieve the input values from the request $username = $_REQUEST['username']; $umbrellaId = $_REQUEST['umbrella']; // Remove the permission from the database \AppSync\UmbrellaAdminFactory::removeUmbrellaAdmin($username, $umbrellaId); // Echo the fact that it succeeded back to the front end echo json_encode("success"); exit; }
/** * The main function for executing the command. */ public function execute() { // Retrieve the current user's username $username = \Current_User::getUsername(); // Retrieve the users permissions $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdminByUsername($username); $umbrellas = array(); $i = 0; // For each permission add the id and name to the umbrella's array foreach ($permissions as $permission) { $umbrella = \AppSync\UmbrellaFactory::getUmbrellaByOrgId($permission->getUmbrellaId()); $umbrellas[$i]['umbrella_id'] = $umbrella->getOrgSyncId(); $umbrellas[$i]['umbrella_name'] = $umbrella->getName(); $i++; } // Json Encode the umbrellas array and pass it to the front end echo json_encode($umbrellas); exit; }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $username = $_REQUEST['username']; // Retrieve the permissions from the database $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdminByUsername($username); $returnData = array(); $i = 0; // For each permission add the id and name to the umbrella's array foreach ($permissions as $permission) { $umbrella = \AppSync\UmbrellaFactory::getUmbrellaByOrgId($permission->getUmbrellaId()); $returnData[$i]['umbrella_id'] = $umbrella->getOrgSyncId(); $returnData[$i]['umbrella_name'] = $umbrella->getName(); $i++; } // Json Encode the umbrellas array and pass it to the front end echo json_encode($returnData); exit; }
public function execute() { // Make sure the user has the appropriate permissions to make changes to the permissions settings. // Basically only deities will have access to permissions. if (!\Current_User::isDeity()) { echo json_encode('user does not have permission to retrieve permissions'); exit; } // Retrieve the permissions from the database $permissions = \AppSync\UmbrellaAdminFactory::getAllUmbrellaAdmins(); $userList = array(); $returnData = array(); // For each permission if the username is not in the userList array add them foreach ($permissions as $permission) { $username = $permission->getUsername(); if (!in_array($username, $userList, true)) { array_push($userList, $username); } } // For each user in the userList array create a permissionList that will be // returned to the front end foreach ($userList as $username) { $permissionList = ""; $first = true; foreach ($permissions as $permission) { if ($permission->getUsername() == $username) { $umbrella = \AppSync\UmbrellaFactory::getUmbrellaByOrgId($permission->getUmbrellaId()); if ($first) { $permissionList = $umbrella->getName(); $first = false; } else { $permissionList .= ', ' . $umbrella->getName(); } } } $node = array('username' => $username, 'permissions' => $permissionList); array_push($returnData, $node); } // Echo the json encoded data back to the front end. 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; }