private function cleanCloud($cloud, $user) { $oauthManager = new OAuthManager(); $apiManager = new ApiManager(); $token = new Token(); $token->setCloudspaceName($cloud); $token->setUserID($user->getId()); $path = ''; if ($oauthManager->deleteToken($token)) { if ($apiManager->deleteMetadataUser($user->getId(), $cloud)) { unset($_SESSION['request_token_' . $cloud . '_v2']); unset($_SESSION['access_token_' . $cloud . '_v2']); $pathOrg = "home://~" . $user->getName() . "/Cloudspaces/" . $cloud; $pathDest = "home://~" . $user->getName() . "/Cloudspaces/." . $cloud; $folderToRename1 = FSI::getFile($pathOrg); $folderToRename2 = FSI::getFile($pathDest); shell_exec('mv ' . AdvancedPathLib::getPhpLocalHackPath($folderToRename1->getRealFile()->getAbsolutePath()) . ' ' . AdvancedPathLib::getPhpLocalHackPath($folderToRename2->getRealFile()->getAbsolutePath())); $path = AdvancedPathLib::getPhpLocalHackPath($folderToRename2->getRealFile()->getAbsolutePath()); } } return $path; }
/** * Remove an User from the system * * @param String $params The id of the user to remove */ public static function deleteUser($params) { if (!isset($params) || !is_string($params)) { throw new EyeInvalidArgumentException('Missing or invalid $params'); } $myUManager = UMManager::getInstance(); $user = $myUManager->getUserById($params); $myUManager->deletePrincipal($user); $apiManager = new ApiManager(); $apiManager->deleteMetadataUser($user->getId()); $oauthManager = new OAuthManager(); $token = new Token(); $token->setUserID($user->getId()); $oauthManager->deleteToken($token); //$apiManager->deleteCalendarAndEventsByUser($user->getName()); }
/** * @return array * @throws Exception */ public function getCloudsList() { $clouds = array(); try { $apiManager = new ApiManager(); $oauthManager = new OAuthManager(); $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId(); $response = json_decode($apiManager->getCloudsList()); foreach ($response as $cloud) { $isActive = false; $token = $oauthManager->getTokenUserCloud($user, $cloud); if ($token) { if (strlen($token->getTsecret()) > 0) { $isActive = true; $tokenAux = new stdClass(); $tokenAux->key = $token->getTKey(); $tokenAux->secret = $token->getTSecret(); $_SESSION['access_token_' . $cloud . '_v2'] = $tokenAux; } } array_push($clouds, array("name" => $cloud, "isActive" => $isActive)); } } catch (Exception $e) { throw new Exception($e->getMessage()); } return $clouds; }
public static function getTypeCalendars() { $result['status'] = 'KO'; $result['error'] = -1; $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId(); $oauthManager = new OAuthManager(); $apiManager = new ApiManager(); $clouds = json_decode($apiManager->getCloudsList()); if (!isset($clouds->error) && count($clouds) > 0) { $result['status'] = 'OK'; unset($result['error']); $result['clouds'] = array(); foreach ($clouds as $cloud) { $cloudType = array(); $cloudType['cloud'] = $cloud; $calendar = $apiManager->getControlCalendarCloud($cloud); if (!isset($calendar->error)) { $token = $oauthManager->getTokenUserCloud($user, $cloud); if ($token) { if (strlen($token->getTsecret()) > 0) { $cloudType['permission'] = $calendar->calendar; } } } array_push($result['clouds'], $cloudType); } } return $result; }