/**
  * 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;
 }