/** * Test delete user home directory */ public function testDeleteUserHomeDirectory() { // test user data $data = ['nick_name' => Rand::getString(32), 'email' => Rand::getString(32), 'api_key' => Rand::getString(32), 'role' => AclModelBase::DEFAULT_ROLE_MEMBER, 'language' => null]; // create a test user $query = $this->userModel->insert()->into('user_list')->values($data); $statement = $this->userModel->prepareStatementForSqlObject($query); $statement->execute(); $testUserId = $this->userModel->getAdapter()->getDriver()->getLastGeneratedValue(); // create a test user's home directory $homeUserDirectory = FileManagerBaseModel::getUserBaseFilesDir($testUserId) . '/' . FileManagerBaseModel::getHomeDirectoryName(); FileSystemUtility::createDir($homeUserDirectory); // fire the delete user event UserEvent::fireUserDeleteEvent($testUserId, $data); // delete the created user $query = $this->userModel->delete()->from('user_list')->where(['user_id' => $testUserId]); $statement = $this->userModel->prepareStatementForSqlObject($query); $statement->execute(); // home directory must be deleted $this->assertFalse(file_exists($homeUserDirectory)); }
/** * Get user path * * @return string */ protected function getUserPath() { return null != $this->getRequest()->getQuery('path', null) ? $this->getRequest()->getQuery('path') : FileManagerBaseModel::getHomeDirectoryName(); }
/** * Generate a tree * * @param array|boolean $userDirectories * @param string $treeId * @param string $currentPath * @param array $filters * @param string $treeClass * @return string */ public function __invoke($userDirectories = [], $treeId, $currentPath, array $filters = [], $treeClass = 'filetree') { $currentPath = $currentPath ? FileManagerBaseModel::processDirectoryPath($currentPath) : FileManagerBaseModel::getHomeDirectoryName(); return $this->getView()->partial('file-manager/patrial/directory-tree', ['id' => $treeId, 'class' => $treeClass, 'items' => $this->processDirectories($userDirectories, $currentPath, $filters), 'cookie_lifetime' => $this->treeCookieLifetimeDays]); }