public function __construct($id = '') { $this->rolesClass = 'Api\\Model\\Languageforge\\Semdomtrans\\SemDomTransRoles'; $this->appName = LfProjectModel::SEMDOMTRANS_APP; $this->semdomVersion = self::SEMDOM_VERSION; $this->sourceLanguageProjectId = new IdReference(); // This must be last, the constructor reads data in from the database which must overwrite the defaults above. parent::__construct($id); }
/** * * @param string $projectId * @param string $mediaType, options are 'image'. * @param string $fileName * @throws \Exception * @return \Api\Model\Shared\Command\UploadResponse */ public static function deleteMediaFile($projectId, $mediaType, $fileName) { $response = new UploadResponse(); $response->result = false; $project = new LfProjectModel($projectId); switch ($mediaType) { case 'sense-image': $folderPath = self::imageFolderPath($project->getAssetsFolderPath()); break; default: $errorMsg = "Error in function deleteImageFile, unsupported mediaType: {$mediaType}"; throw new \Exception($errorMsg); $data = new ErrorResult(); $data->errorType = 'Exception'; $data->errorMessage = $errorMsg; return $response; } $filePath = $folderPath . '/' . $fileName; if (file_exists($filePath) and !is_dir($filePath)) { if (@unlink($filePath)) { $data = new MediaResult(); $data->path = self::imageFolderPath($project->getAssetsRelativePath()); $data->fileName = $fileName; $response->result = true; } else { $data = new ErrorResult(); $data->errorType = 'UserMessage'; $data->errorMessage = "{$fileName} could not be deleted. Contact your Site Administrator."; } return $response; } $data = new ErrorResult(); $data->errorType = 'UserMessage'; $data->errorMessage = "{$fileName} does not exist in this project. Contact your Site Administrator."; return $response; }
/** * Cleanup associated project files */ protected function cleanup() { parent::cleanup(); if (!is_null($this->projectCode)) { $projectFilename = strtolower($this->projectCode); $stateFilename = strtolower($this->projectCode) . '.state'; $lfmergePaths = SendReceiveCommands::getLFMergePaths(); foreach ($lfmergePaths as $key => $path) { if (!is_null($path)) { if ($key == "workPath") { FileUtilities::removeFolderAndAllContents($lfmergePaths->workPath . DIRECTORY_SEPARATOR . $projectFilename); } if (file_exists($path . DIRECTORY_SEPARATOR . $projectFilename)) { unlink($path . DIRECTORY_SEPARATOR . $projectFilename); } if (file_exists($path . DIRECTORY_SEPARATOR . $stateFilename)) { unlink($path . DIRECTORY_SEPARATOR . $stateFilename); } } } } }
public function getPublicSettings($userId) { $settings = parent::getPublicSettings($userId); $settings['currentUserRole'] = $this->users[$userId]->role; return array_merge($settings, LexBaseViewDto::encode($this->id->asString(), $userId)); }