Example #1
0
 protected function tearDown()
 {
     foreach ($this->tmpDirs as $dir) {
         \OC_Helper::rmdirr($dir);
     }
     parent::tearDown();
 }
Example #2
0
 public function tearDown()
 {
     foreach ($this->tmpDirs as $dir) {
         \OC_Helper::rmdirr($dir);
     }
     \OC\Files\Filesystem::clearMounts();
     \OC_User::setUserId('');
 }
 protected function tearDown()
 {
     foreach ($this->tmpDirs as $dir) {
         \OC_Helper::rmdirr($dir);
     }
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     \OC_User::setUserId('');
     parent::tearDown();
 }
Example #4
0
 public function tearDown()
 {
     $u = new OC_User();
     foreach ($this->users as $user) {
         $u->deleteUser($user);
     }
     foreach ($this->tmpfiles as $file) {
         \OC_Helper::rmdirr($file);
     }
 }
Example #5
0
 public function run(IOutput $output)
 {
     if (!\OC_Template::isAssetPipelineEnabled()) {
         $output->info('Asset pipeline disabled -> nothing to do');
         return;
     }
     $assetDir = \OC::$server->getConfig()->getSystemValue('assetdirectory', \OC::$SERVERROOT) . '/assets';
     \OC_Helper::rmdirr($assetDir, false);
     $output->info('Asset cache cleared.');
 }
Example #6
0
 public function run()
 {
     if (!\OC_Template::isAssetPipelineEnabled()) {
         $this->emit('\\OC\\Repair', 'info', array('Asset pipeline disabled -> nothing to do'));
         return;
     }
     $assetDir = \OC::$server->getConfig()->getSystemValue('assetdirectory', \OC::$SERVERROOT) . '/assets';
     \OC_Helper::rmdirr($assetDir, false);
     $this->emit('\\OC\\Repair', 'info', array('Asset cache cleared.'));
 }
Example #7
0
 public function run()
 {
     if (!\OC_Template::isAssetPipelineEnabled()) {
         $this->emit('\\OC\\Repair', 'info', array('Asset pipeline disabled -> nothing to do'));
         return;
     }
     $assetDir = \OC::$SERVERROOT . '/assets';
     \OC_Helper::rmdirr($assetDir, false);
     $this->emit('\\OC\\Repair', 'info', array('Asset cache cleared.'));
 }
Example #8
0
 public static function getPackage($url, $version)
 {
     $path = \OC_Helper::tmpFile();
     if (!copy($url, $path)) {
         \OC_Log::write(App::APP_ID, "Failed to download {$url} package to {$path}", \OC_Log::ERROR);
         return false;
     }
     //Mimetype bug workaround
     $mime = rtrim(\OC_Helper::getMimeType($path), ';');
     if ($mime == 'application/zip') {
         rename($path, $path . '.zip');
         $path .= '.zip';
     } elseif ($mime == 'application/x-gzip') {
         rename($path, $path . '.tgz');
         $path .= '.tgz';
     } elseif ($mime == 'application/x-bzip2') {
         rename($path, $path . '.tar.bz2');
         $path .= '.tar.bz2';
     } else {
         \OC_Log::write(App::APP_ID, 'Archives of type ' . $mime . ' are not supported', \OC_Log::ERROR);
         return false;
     }
     $extractDir = self::getPackageDir($version);
     if (!mkdir($extractDir, 0777, true)) {
         \OC_Log::write(App::APP_ID, 'Unable to create temporary directory', \OC_Log::ERROR);
         return false;
     }
     $archive = \OC_Archive::open($path);
     if ($archive) {
         $archive->extract($extractDir);
     } else {
         \OC_Log::write(App::APP_ID, "Failed to open package {$path}", \OC_Log::ERROR);
         \OC_Helper::rmdirr($extractDir);
         @unlink($path);
         return false;
     }
     return $extractDir . DIRECTORY_SEPARATOR . self::PACKAGE_ROOT;
 }
 protected function tearDown()
 {
     foreach ($this->tmpDirs as $dir) {
         \OC_Helper::rmdirr($dir);
     }
     $this->logout();
     $this->invokePrivate('\\OC\\Files\\Filesystem', 'normalizedPathCache', [null]);
     parent::tearDown();
 }
Example #10
0
 public static function update($version, $backupBase)
 {
     if (!is_dir($backupBase)) {
         throw new \Exception("Backup directory {$backupBase} is not found");
     }
     set_include_path($backupBase . PATH_SEPARATOR . $backupBase . '/core/lib' . PATH_SEPARATOR . $backupBase . '/core/config' . PATH_SEPARATOR . $backupBase . '/3rdparty' . PATH_SEPARATOR . $backupBase . '/apps' . PATH_SEPARATOR . get_include_path());
     $tempDir = self::getTempDir();
     Helper::mkdir($tempDir, true);
     try {
         foreach (self::prepare($version) as $location) {
             Helper::move($location['src'], $location['dst']);
             self::$processed[] = array('src' => $location['dst'], 'dst' => $location['src']);
         }
     } catch (\Exception $e) {
         self::rollBack();
         self::cleanUp();
         throw $e;
     }
     $config = "/config/config.php";
     copy($backupBase . "/" . Helper::CORE_DIRNAME . $config, \OC::$SERVERROOT . $config);
     // zip backup
     $zip = new \ZipArchive();
     if ($zip->open($backupBase . ".zip", \ZIPARCHIVE::CREATE) === true) {
         Helper::addDirectoryToZip($zip, $backupBase, $backupBase);
         $zip->close();
         \OC_Helper::rmdirr($backupBase);
     }
     // Disable removed apps
     foreach (self::getAppsToRemove() as $appId) {
         \OC_App::disable($appId);
     }
     return true;
 }
Example #11
0
 /**
  * Removes an app
  * @param string $name name of the application to remove
  * @param array $options options
  * @return boolean
  *
  * This function removes an app. $options is an associative array. The
  * following keys are optional:ja
  *   - keeppreferences: boolean, if true the user preferences won't be deleted
  *   - keepappconfig: boolean, if true the config will be kept
  *   - keeptables: boolean, if true the database will be kept
  *   - keepfiles: boolean, if true the user files will be kept
  *
  * This function works as follows
  *   -# including appinfo/remove.php
  *   -# removing the files
  *
  * The function will not delete preferences, tables and the configuration,
  * this has to be done by the function oc_app_uninstall().
  */
 public static function removeApp($name, $options = array())
 {
     if (isset($options['keeppreferences']) and $options['keeppreferences'] == false) {
         // todo
         // remove preferences
     }
     if (isset($options['keepappconfig']) and $options['keepappconfig'] == false) {
         // todo
         // remove app config
     }
     if (isset($options['keeptables']) and $options['keeptables'] == false) {
         // todo
         // remove app database tables
     }
     if (isset($options['keepfiles']) and $options['keepfiles'] == false) {
         // todo
         // remove user files
     }
     if (OC_Installer::isDownloaded($name)) {
         $appdir = OC_App::getInstallPath() . '/' . $name;
         OC_Helper::rmdirr($appdir);
         return true;
     } else {
         OC_Log::write('core', 'can\'t remove app ' . $name . '. It is not installed.', OC_Log::ERROR);
         return false;
     }
 }
Example #12
0
	protected function tearDown() {
		\OC_Helper::rmdirr($this->tmpDir);
		parent::tearDown();
	}
Example #13
0
 /**
  * Silently remove the filesystem item
  * Used for cleanup
  * @param string $path
  */
 public static function removeIfExists($path)
 {
     if (!file_exists($path)) {
         return;
     }
     if (is_dir($path)) {
         \OC_Helper::rmdirr($path);
     } else {
         @unlink($path);
     }
 }
 /**
  * @brief Installs an app
  * @param $data array with all information
  * @returns integer
  *
  * This function installs an app. All information needed are passed in the
  * associative array $data.
  * The following keys are required:
  *   - source: string, can be "path" or "http"
  *
  * One of the following keys is required:
  *   - path: path to the file containing the app
  *   - href: link to the downloadable file containing the app
  *
  * The following keys are optional:
  *   - pretend: boolean, if set true the system won't do anything
  *   - noinstall: boolean, if true appinfo/install.php won't be loaded
  *   - inactive: boolean, if set true the appconfig/app.sample.php won't be
  *     renamed
  *
  * This function works as follows
  *   -# fetching the file
  *   -# unzipping it
  *   -# check the code
  *   -# installing the database at appinfo/database.xml
  *   -# including appinfo/install.php
  *   -# setting the installed version
  *
  * It is the task of oc_app_install to create the tables and do whatever is
  * needed to get the app working.
  */
 public static function installApp($data = array())
 {
     if (!isset($data['source'])) {
         OC_Log::write('core', 'No source specified when installing app', OC_Log::ERROR);
         return false;
     }
     //download the file if necesary
     if ($data['source'] == 'http') {
         $path = OC_Helper::tmpFile();
         if (!isset($data['href'])) {
             OC_Log::write('core', 'No href specified when installing app from http', OC_Log::ERROR);
             return false;
         }
         copy($data['href'], $path);
     } else {
         if (!isset($data['path'])) {
             OC_Log::write('core', 'No path specified when installing app from local file', OC_Log::ERROR);
             return false;
         }
         $path = $data['path'];
     }
     //detect the archive type
     $mime = OC_Helper::getMimeType($path);
     if ($mime == 'application/zip') {
         rename($path, $path . '.zip');
         $path .= '.zip';
     } elseif ($mime == 'application/x-gzip') {
         rename($path, $path . '.tgz');
         $path .= '.tgz';
     } else {
         OC_Log::write('core', 'Archives of type ' . $mime . ' are not supported', OC_Log::ERROR);
         return false;
     }
     //extract the archive in a temporary folder
     $extractDir = OC_Helper::tmpFolder();
     OC_Helper::rmdirr($extractDir);
     mkdir($extractDir);
     if ($archive = OC_Archive::open($path)) {
         $archive->extract($extractDir);
     } else {
         OC_Log::write('core', 'Failed to open archive when installing app', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     //load the info.xml file of the app
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         //try to find it in a subdir
         $dh = opendir($extractDir);
         while ($folder = readdir($dh)) {
             if (substr($folder, 0, 1) != '.' and is_dir($extractDir . '/' . $folder)) {
                 if (is_file($extractDir . '/' . $folder . '/appinfo/info.xml')) {
                     $extractDir .= '/' . $folder;
                 }
             }
         }
     }
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         OC_Log::write('core', 'App does not provide an info.xml file', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     $info = OC_App::getAppInfo($extractDir . '/appinfo/info.xml', true);
     $basedir = OC::$APPSROOT . '/apps/' . $info['id'];
     // check the code for not allowed calls
     if (!OC_Installer::checkCode($info['id'], $extractDir)) {
         OC_Log::write('core', 'App can\'t be installed because of not allowed code in the App', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         return false;
     }
     // check if the app is compatible with this version of ownCloud
     $version = OC_Util::getVersion();
     if (!isset($info['require']) or $version[0] > $info['require']) {
         OC_Log::write('core', 'App can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         return false;
     }
     //check if an app with the same id is already installed
     if (self::isInstalled($info['id'])) {
         OC_Log::write('core', 'App already installed', OC_Log::WARN);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     //check if the destination directory already exists
     if (is_dir($basedir)) {
         OC_Log::write('core', 'App directory already exists', OC_Log::WARN);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     if (isset($data['pretent']) and $data['pretent'] == true) {
         return false;
     }
     //copy the app to the correct place
     if (@(!mkdir($basedir))) {
         OC_Log::write('core', 'Can\'t create app folder. Please fix permissions. (' . $basedir . ')', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     OC_Helper::copyr($extractDir, $basedir);
     //remove temporary files
     OC_Helper::rmdirr($extractDir);
     //install the database
     if (is_file($basedir . '/appinfo/database.xml')) {
         OC_DB::createDbFromStructure($basedir . '/appinfo/database.xml');
     }
     //run appinfo/install.php
     if ((!isset($data['noinstall']) or $data['noinstall'] == false) and file_exists($basedir . '/appinfo/install.php')) {
         include $basedir . '/appinfo/install.php';
     }
     //set the installed version
     OC_Appconfig::setValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id']));
     OC_Appconfig::setValue($info['id'], 'enabled', 'no');
     //set remote/public handelers
     foreach ($info['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, '/apps/' . $info['id'] . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, '/apps/' . $info['id'] . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info['id'];
 }
 /**
  * @brief Installs an app
  * @param $data array with all information
  * @returns integer
  *
  * This function installs an app. All information needed are passed in the
  * associative array $data.
  * The following keys are required:
  *   - source: string, can be "path" or "http"
  *
  * One of the following keys is required:
  *   - path: path to the file containing the app
  *   - href: link to the downloadable file containing the app
  *
  * The following keys are optional:
  *   - pretend: boolean, if set true the system won't do anything
  *   - noinstall: boolean, if true appinfo/install.php won't be loaded
  *   - inactive: boolean, if set true the appconfig/app.sample.php won't be
  *     renamed
  *
  * This function works as follows
  *   -# fetching the file
  *   -# unzipping it
  *   -# installing the database at appinfo/database.xml
  *   -# including appinfo/install.php
  *   -# setting the installed version
  *
  * It is the task of oc_app_install to create the tables and do whatever is
  * needed to get the app working.
  */
 public static function installApp($data = array())
 {
     if (!isset($data['source'])) {
         if (defined("DEBUG") && DEBUG) {
             error_log("No source specified when installing app");
         }
         return false;
     }
     //download the file if necesary
     if ($data['source'] == 'http') {
         $path = tempnam(sys_get_temp_dir(), 'oc_installer_');
         if (!isset($data['href'])) {
             if (defined("DEBUG") && DEBUG) {
                 error_log("No href specified when installing app from http");
             }
             return false;
         }
         copy($data['href'], $path);
     } else {
         if (!isset($data['path'])) {
             if (defined("DEBUG") && DEBUG) {
                 error_log("No path specified when installing app from local file");
             }
             return false;
         }
         $path = $data['path'];
     }
     //extract the archive in a temporary folder
     $extractDir = tempnam(sys_get_temp_dir(), 'oc_installer_uncompressed_');
     unlink($extractDir);
     mkdir($extractDir);
     $zip = new ZipArchive();
     if ($zip->open($path) === true) {
         $zip->extractTo($extractDir);
         $zip->close();
     } else {
         if (defined("DEBUG") && DEBUG) {
             error_log("Failed to open archive when installing app");
         }
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     //load the info.xml file of the app
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         if (defined("DEBUG") && DEBUG) {
             error_log("App does not provide an info.xml file");
         }
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     $info = OC_App::getAppInfo($extractDir . '/appinfo/info.xml');
     $basedir = OC::$SERVERROOT . '/apps/' . $info['id'];
     //check if an app with the same id is already installed
     if (self::isInstalled($info['id'])) {
         if (defined("DEBUG") && DEBUG) {
             error_log("App already installed");
         }
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     //check if the destination directory already exists
     if (is_dir($basedir)) {
         if (defined("DEBUG") && DEBUG) {
             error_log("App's directory already exists");
         }
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     if (isset($data['pretent']) and $data['pretent'] == true) {
         return false;
     }
     //copy the app to the correct place
     if (!mkdir($basedir)) {
         if (defined("DEBUG") && DEBUG) {
             error_log('Can\'t create app folder (' . $basedir . ')');
         }
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     OC_Helper::copyr($extractDir, $basedir);
     //remove temporary files
     OC_Helper::rmdirr($extractDir);
     if ($data['source'] == 'http') {
         unlink($path);
     }
     //install the database
     if (is_file($basedir . '/appinfo/database.xml')) {
         OC_DB::createDbFromStructure($basedir . '/appinfo/database.xml');
     }
     //run appinfo/install.php
     if (!isset($data['noinstall']) or $data['noinstall'] == false and is_file($basedir . '/appinfo/install.php')) {
         include $basedir . '/appinfo/install.php';
     }
     //set the installed version
     OC_Appconfig::setValue($info['id'], 'installed_version', $info['version']);
     OC_Appconfig::setValue($info['id'], 'enabled', 'no');
     return true;
 }
 protected function tearDown()
 {
     \OC_Helper::rmdirr($this->baseDir);
     $this->baseDir = null;
     parent::tearDown();
 }
Example #17
0
 public static function update($version, $backupBase)
 {
     if (!is_dir($backupBase)) {
         throw new \Exception("Backup directory {$backupBase} is not found");
     }
     set_include_path($backupBase . PATH_SEPARATOR . $backupBase . '/core/lib' . PATH_SEPARATOR . $backupBase . '/core/config' . PATH_SEPARATOR . $backupBase . '/3rdparty' . PATH_SEPARATOR . $backupBase . '/apps' . PATH_SEPARATOR . get_include_path());
     $tempDir = self::getTempDir();
     Helper::mkdir($tempDir, true);
     try {
         foreach (self::prepare($version) as $location) {
             Helper::move($location['src'], $location['dst']);
             self::$processed[] = array('src' => $location['dst'], 'dst' => $location['src']);
         }
     } catch (\Exception $e) {
         App::log('Something went wrong. Rolling back.');
         self::rollBack();
         self::cleanUp();
         throw $e;
     }
     // move old config files
     $backupConfigPath = $backupBase . "/" . Helper::CORE_DIRNAME . "/config/";
     foreach (glob($backupConfigPath . "*.php") as $configFile) {
         $target = \OC::$SERVERROOT . "/config/" . basename($configFile);
         if (!file_exists($target)) {
             copy($configFile, $target);
         }
     }
     // zip backup
     $zip = new \ZipArchive();
     if ($zip->open($backupBase . ".zip", \ZIPARCHIVE::CREATE) === true) {
         Helper::addDirectoryToZip($zip, $backupBase, $backupBase);
         $zip->close();
         \OC_Helper::rmdirr($backupBase);
     }
     // Disable removed apps
     foreach (self::getAppsToRemove() as $appId) {
         \OC_App::disable($appId);
     }
     return true;
 }
Example #18
0
 /**
  * @brief delete a user
  * @param $uid The username of the user to delete
  * @returns true/false
  *
  * Deletes a user
  */
 public static function deleteUser($uid)
 {
     $run = true;
     OC_Hook::emit("OC_User", "pre_deleteUser", array("run" => &$run, "uid" => $uid));
     if ($run) {
         //delete the user from all backends
         foreach (self::$_usedBackends as $backend) {
             $backend->deleteUser($uid);
         }
         if (self::userExists($uid)) {
             return false;
         }
         // We have to delete the user from all groups
         foreach (OC_Group::getUserGroups($uid) as $i) {
             OC_Group::removeFromGroup($uid, $i);
         }
         // Delete the user's keys in preferences
         OC_Preferences::deleteUser($uid);
         // Delete user files in /data/
         OC_Helper::rmdirr(OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $uid . '/');
         // Emit and exit
         OC_Hook::emit("OC_User", "post_deleteUser", array("uid" => $uid));
         return true;
     } else {
         return false;
     }
 }
Example #19
0
 /**
  * Tests recursive folder deletion with rmdirr()
  */
 public function testRecursiveFolderDeletion()
 {
     $baseDir = \OC_Helper::tmpFolder() . '/';
     mkdir($baseDir . 'a/b/c/d/e', 0777, true);
     mkdir($baseDir . 'a/b/c1/d/e', 0777, true);
     mkdir($baseDir . 'a/b/c2/d/e', 0777, true);
     mkdir($baseDir . 'a/b1/c1/d/e', 0777, true);
     mkdir($baseDir . 'a/b2/c1/d/e', 0777, true);
     mkdir($baseDir . 'a/b3/c1/d/e', 0777, true);
     mkdir($baseDir . 'a1/b', 0777, true);
     mkdir($baseDir . 'a1/c', 0777, true);
     file_put_contents($baseDir . 'a/test.txt', 'Hello file!');
     file_put_contents($baseDir . 'a/b1/c1/test one.txt', 'Hello file one!');
     file_put_contents($baseDir . 'a1/b/test two.txt', 'Hello file two!');
     \OC_Helper::rmdirr($baseDir . 'a');
     $this->assertFalse(file_exists($baseDir . 'a'));
     $this->assertTrue(file_exists($baseDir . 'a1'));
     \OC_Helper::rmdirr($baseDir);
     $this->assertFalse(file_exists($baseDir));
 }
Example #20
0
 public function tearDown()
 {
     foreach ($this->tmpDirs as $dir) {
         OC_Helper::rmdirr($dir);
     }
 }
Example #21
0
 public function tearDown()
 {
     \OC_Helper::rmdirr($this->tmpDir);
 }
Example #22
0
 /**
  * @brief Recusive deletion of folders
  * @param string $dir path to the folder
  *
  */
 static function rmdirr($dir)
 {
     \OC_Helper::rmdirr($dir);
 }
Example #23
0
 /**
  * Delete the user
  *
  * @return bool
  */
 public function delete()
 {
     if ($this->emitter) {
         $this->emitter->emit('\\OC\\User', 'preDelete', array($this));
     }
     $result = $this->backend->deleteUser($this->uid);
     if ($result) {
         // FIXME: Feels like an hack - suggestions?
         // We have to delete the user from all groups
         foreach (\OC_Group::getUserGroups($this->uid) as $i) {
             \OC_Group::removeFromGroup($this->uid, $i);
         }
         // Delete the user's keys in preferences
         \OC::$server->getConfig()->deleteAllUserValues($this->uid);
         // Delete user files in /data/
         \OC_Helper::rmdirr(\OC_User::getHome($this->uid));
         // Delete the users entry in the storage table
         \OC\Files\Cache\Storage::remove('home::' . $this->uid);
         \OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid);
         \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this);
     }
     if ($this->emitter) {
         $this->emitter->emit('\\OC\\User', 'postDelete', array($this));
     }
     return !($result === false);
 }
Example #24
0
 /**
  * @brief Recusive deletion of folders
  * @param string $dir path to the folder
  *
  * @return bool
  */
 static function rmdirr($dir)
 {
     return \OC_Helper::rmdirr($dir);
 }
Example #25
0
 public function cleanUp()
 {
     \OC_Helper::rmdirr($this->datadir);
 }
Example #26
0
 /**
  * @brief delete a user
  * @param string $uid The username of the user to delete
  * @return bool
  *
  * Deletes a user
  */
 public static function deleteUser($uid)
 {
     $user = self::getManager()->get($uid);
     if ($user) {
         $result = $user->delete();
         // if delete was successful we clean-up the rest
         if ($result) {
             // We have to delete the user from all groups
             foreach (OC_Group::getUserGroups($uid) as $i) {
                 OC_Group::removeFromGroup($uid, $i);
             }
             // Delete the user's keys in preferences
             OC_Preferences::deleteUser($uid);
             // Delete user files in /data/
             $home = \OC_User::getHome($uid);
             OC_Helper::rmdirr($home);
             // Delete the users entry in the storage table
             \OC\Files\Cache\Storage::remove('home::' . $uid);
             \OC\Files\Cache\Storage::remove('local::' . $home . '/');
             // Remove it from the Cache
             self::getManager()->delete($uid);
         }
         return true;
     } else {
         return false;
     }
 }
Example #27
0
 /**
  * @param string[] $files
  */
 protected function cleanFiles($files)
 {
     foreach ($files as $file) {
         if (file_exists($file)) {
             try {
                 \OC_Helper::rmdirr($file);
             } catch (\UnexpectedValueException $ex) {
                 $this->log->warning("Error deleting temporary file/folder: {file} - Reason: {error}", ['file' => $file, 'error' => $ex->getMessage()]);
             }
         }
     }
 }
Example #28
0
 public function tearDown()
 {
     \OC_Helper::rmdirr($this->tmpDir);
     unset($this->instance);
 }