• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/monograph/ArtworkFileDAODelegate.inc.php

00001 <?php
00002 
00020 import('classes.monograph.ArtworkFile');
00021 import('classes.monograph.MonographFileDAODelegate');
00022 
00023 class ArtworkFileDAODelegate extends MonographFileDAODelegate {
00027    function ArtworkFileDAODelegate() {
00028       parent::MonographFileDAODelegate();
00029    }
00030 
00031 
00032    //
00033    // Public methods
00034    //
00040    function &insertObject(&$artworkFile, $sourceFile, $isUpload = false) {
00041       // First insert the data for the super-class.
00042       $artworkFile =& parent::insertObject($artworkFile, $sourceFile, $isUpload);
00043       if (is_null($artworkFile)) return $artworkFile;
00044 
00045       // Now insert the artwork-specific data.
00046       $this->update(
00047          'INSERT INTO monograph_artwork_files
00048             (file_id, revision, caption, chapter_id, contact_author, copyright_owner, copyright_owner_contact, credit, permission_file_id, permission_terms)
00049          VALUES
00050             (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
00051          array(
00052             $artworkFile->getFileId(),
00053             $artworkFile->getRevision(),
00054             $artworkFile->getCaption(),
00055             $artworkFile->getChapterId(),
00056             $artworkFile->getContactAuthor(),
00057             $artworkFile->getCopyrightOwner(),
00058             $artworkFile->getCopyrightOwnerContactDetails(),
00059             $artworkFile->getCredit(),
00060             $artworkFile->getPermissionFileId(),
00061             $artworkFile->getPermissionTerms()
00062          )
00063       );
00064 
00065       return $artworkFile;
00066    }
00067 
00073    function updateObject(&$artworkFile, &$previousFile) {
00074       // Update the parent class table first.
00075       if (!parent::updateObject($artworkFile, $previousFile)) return false;
00076 
00077       // Now update the artwork file table.
00078       $this->update(
00079          'UPDATE monograph_artwork_files
00080             SET
00081                file_id = ?,
00082                revision = ?,
00083                caption = ?,
00084                chapter_id = ?,
00085                contact_author = ?,
00086                copyright_owner = ?,
00087                copyright_owner_contact = ?,
00088                credit = ?,
00089                permission_file_id = ?,
00090                permission_terms = ?
00091             WHERE file_id = ? and revision = ?',
00092          array(
00093             (int)$artworkFile->getFileId(),
00094             (int)$artworkFile->getRevision(),
00095             $artworkFile->getCaption(),
00096             is_null($artworkFile->getChapterId()) ? null : (int)$artworkFile->getChapterId(),
00097             $artworkFile->getContactAuthor(),
00098             $artworkFile->getCopyrightOwner(),
00099             $artworkFile->getCopyrightOwnerContactDetails(),
00100             $artworkFile->getCredit(),
00101             is_null($artworkFile->getPermissionFileId()) ? null : (int)$artworkFile->getPermissionFileId(),
00102             $artworkFile->getPermissionTerms(),
00103             (int)$previousFile->getFileId(),
00104             (int)$previousFile->getRevision()
00105          )
00106       );
00107       return true;
00108    }
00109 
00113    function deleteObject(&$submissionFile) {
00114       // First delete the monograph file entry.
00115       if (!parent::deleteObject($submissionFile)) return false;
00116 
00117       // Delete the artwork file entry.
00118       return $this->update(
00119          'DELETE FROM monograph_artwork_files
00120           WHERE file_id = ? AND revision = ?',
00121          array(
00122             (int)$submissionFile->getFileId(),
00123             (int)$submissionFile->getRevision()
00124          ));
00125    }
00126 
00131    function &fromRow(&$row) {
00132       $artworkFile =& parent::fromRow($row);
00133       $artworkFile->setCredit($row['credit']);
00134       $artworkFile->setCaption($row['caption']);
00135       $artworkFile->setChapterId(is_null($row['chapter_id']) ? null : (int)$row['chapter_id']);
00136       $artworkFile->setContactAuthor($row['contact_author']);
00137       $artworkFile->setCopyrightOwner($row['copyright_owner']);
00138       $artworkFile->setPermissionTerms($row['permission_terms']);
00139       $artworkFile->setPermissionFileId(is_null($row['permission_file_id']) ? null : (int)$row['permission_file_id']);
00140       $artworkFile->setCopyrightOwnerContactDetails($row['copyright_owner_contact']);
00141 
00142       return $artworkFile;
00143    }
00144 
00149    function newDataObject() {
00150       return new ArtworkFile();
00151    }
00152 }
00153 
00154 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1