/**
  * Place a user or users into a group. User can be a single user id or and array of ids
  *
  * @param int $user_id (can be array of user id's), int $group_id (groups id)
  * @return boolean (success or not)
  */
 public function removeGroupAccount($user_id, $group_id)
 {
     // Use the UtilityFunctions to retrieve the info to be passed to the API
     $key = \AppSync\UtilityFunctions::getOrgSyncKey();
     $base_url = \AppSync\UtilityFunctions::getOrgSyncURL();
     $id = \AppSync\UtilityFunctions::getIDFromUsername($user_id);
     // Create the url
     $import_url = $base_url . "groups/{$group_id}/accounts/remove";
     // Initialize curl
     $curl = curl_init();
     curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $import_url, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => "ids={$id}&key={$key}"));
     // Execute the curl request and store the result
     $result = curl_exec($curl);
     // Close curl
     curl_close($curl);
     // Check to make sure the result was valid
     if ($result) {
         $result = json_decode($result);
         if (is_object($result) && $result->success == "true") {
             return TRUE;
         } else {
             // Log that an attempt to interact with the API failed
             $logEntry = new \AppSync\LogEntry(null, 'Attempted to from user from group in Orgsync API via removeGroupAccount function, response was ' . $result->message, \Current_User::getUsername(), time());
             \AppSync\LogEntryFactory::save($logEntry);
             return FALSE;
         }
     } else {
         // Log that an attempt to interact with the API failed
         $logEntry = new \AppSync\LogEntry(null, 'Attempted to from user from group in Orgsync API via removeGroupAccount function, response was ' . $result->message, \Current_User::getUsername(), time());
         \AppSync\LogEntryFactory::save($logEntry);
         return FALSE;
     }
 }
 /**
  * Retrieves the group members for a given groupId.
  * @return group members array
  */
 public function getGroupMembers($group_id)
 {
     // Use the UtilityFunctions to retrieve the info to be passed to the API
     $key = \AppSync\UtilityFunctions::getOrgSyncKey();
     $base_url = \AppSync\UtilityFunctions::getOrgSyncURL();
     // Initialize the curl request
     $curl = curl_init();
     curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $base_url . "groups/{$group_id}/accounts?key={$key}"));
     // Execute the curl request and store the result
     $group_members = curl_exec($curl);
     // Check to make sure the result was valid
     if ($group_members) {
         $group_members = json_decode($group_members);
     } else {
         $group_members = FALSE;
     }
     // Close curl
     curl_close($curl);
     return $group_members;
 }
예제 #3
0
 private function getAllOrganizations()
 {
     // Use the UtilityFunctions to retrieve the info to be passed to the API
     $key = \AppSync\UtilityFunctions::getOrgSyncKey();
     $base_url = \AppSync\UtilityFunctions::getOrgSyncURL();
     // Initialize curl
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     //Request list of all orginizations
     curl_setopt($curl, CURLOPT_URL, $base_url . "orgs?key={$key}");
     // Execute the curl request and store the result
     $all_org = curl_exec($curl);
     // Check to make sure the result was valid
     if ($all_org) {
         $all_org = json_decode($all_org);
     } else {
         $all_org = FALSE;
     }
     // Close curl
     curl_close($curl);
     return $all_org;
 }