00001 <?php
00002
00017 import('classes.monograph.Monograph');
00018
00019 class MonographDAO extends DAO {
00020 var $authorDao;
00021 var $cache;
00022
00026 function MonographDAO() {
00027 parent::DAO();
00028 $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
00029 }
00030
00037 function _cacheMiss(&$cache, $id) {
00038 $monograph =& $this->getMonograph($id, null, false);
00039 $cache->setCache($id, $monograph);
00040 return $monograph;
00041 }
00042
00047 function &_getCache() {
00048 if (!isset($this->cache)) {
00049 $cacheManager =& CacheManager::getManager();
00050 $this->cache =& $cacheManager->getObjectCache('monographs', 0, array(&$this, '_cacheMiss'));
00051 }
00052 return $this->cache;
00053 }
00054
00059 function getLocaleFieldNames() {
00060 return array(
00061 'title', 'subtitle', 'cleanTitle', 'prefix',
00062 'abstract',
00063 'discipline', 'subjectClass', 'subject',
00064 'coverageGeo', 'coverageChron', 'coverageSample',
00065 'type', 'sponsor', 'rights', 'source', 'copyrightNotice',
00066 );
00067 }
00068
00073 function updateLocaleFields(&$monograph) {
00074 $this->updateDataObjectSettings('monograph_settings', $monograph, array(
00075 'monograph_id' => $monograph->getId()
00076 ));
00077 }
00078
00086 function &getById($monographId, $pressId = null, $useCache = false) {
00087 if ($useCache) {
00088 $cache =& $this->_getCache();
00089 $returner =& $cache->get($monographId);
00090 if ($returner && $pressId != null && $pressId != $returner->getPressId()) $returner = null;
00091 return $returner;
00092 }
00093
00094 $primaryLocale = AppLocale::getPrimaryLocale();
00095 $locale = AppLocale::getLocale();
00096 $params = array(
00097 'title', $primaryLocale,
00098 'title', $locale,
00099 'abbrev', $primaryLocale,
00100 'abbrev', $locale,
00101 (int) $monographId
00102 );
00103 if ($pressId) $params[] = (int) $pressId;
00104
00105 $result =& $this->retrieve(
00106 'SELECT m.*, pm.date_published,
00107 COALESCE(stl.setting_value, stpl.setting_value) AS series_title,
00108 COALESCE(sal.setting_value, sapl.setting_value) AS series_abbrev
00109 FROM monographs m
00110 LEFT JOIN series s ON s.series_id = m.series_id
00111 LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?)
00112 LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?)
00113 LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?)
00114 LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?)
00115 LEFT JOIN published_monographs pm ON (m.monograph_id = pm.monograph_id)
00116 WHERE m.monograph_id = ?
00117 ' . ($pressId?' AND m.press_id = ?':''),
00118 $params
00119 );
00120
00121 $returner = null;
00122 if ($result->RecordCount() != 0) {
00123 $returner =& $this->_fromRow($result->GetRowAssoc(false));
00124 }
00125
00126 $result->Close();
00127 unset($result);
00128
00129 return $returner;
00130 }
00131
00137 function &_fromRow(&$row) {
00138 $monograph = $this->newDataObject();
00139 $this->_monographFromRow($monograph, $row);
00140 return $monograph;
00141 }
00142
00147 function newDataObject() {
00148 return new Monograph();
00149 }
00150
00156 function _monographFromRow(&$monograph, &$row) {
00157 $monograph->setId($row['monograph_id']);
00158 $monograph->setLocale($row['locale']);
00159 $monograph->setUserId($row['user_id']);
00160 $monograph->setPressId($row['press_id']);
00161 $monograph->setStatus($row['status']);
00162 $monograph->setSeriesId($row['series_id']);
00163 $monograph->setSeriesPosition($row['series_position']);
00164 $monograph->setSeriesAbbrev(isset($row['series_abbrev'])?$row['series_abbrev']:null);
00165 $monograph->setLanguage($row['language']);
00166 $monograph->setCommentsToEditor($row['comments_to_ed']);
00167 $monograph->setDateSubmitted($row['date_submitted']);
00168 $monograph->setDateStatusModified($this->datetimeFromDB($row['date_status_modified']));
00169 $monograph->setLastModified($this->datetimeFromDB($row['last_modified']));
00170 $monograph->setStageId($row['stage_id']);
00171 $monograph->setStatus($row['status']);
00172 $monograph->setSubmissionProgress($row['submission_progress']);
00173 $monograph->setWorkType($row['edited_volume']);
00174 $monograph->setDatePublished($this->datetimeFromDB(isset($row['date_published'])?$row['date_published']:null));
00175
00176 $this->getDataObjectSettings('monograph_settings', 'monograph_id', $row['monograph_id'], $monograph);
00177
00178 HookRegistry::call('MonographDAO::_monographFromRow', array(&$monograph, &$row));
00179 }
00180
00186 function insertMonograph(&$monograph) {
00187 $monograph->stampModified();
00188 $this->update(
00189 sprintf('INSERT INTO monographs
00190 (locale, user_id, press_id, series_id, series_position, language, comments_to_ed, date_submitted, date_status_modified, last_modified, status, submission_progress, stage_id, pages, hide_author, comments_status, edited_volume)
00191 VALUES
00192 (?, ?, ?, ?, ?, ?, ?, %s, %s, %s, ?, ?, ?, ?, ?, ?, ?)',
00193 $this->datetimeToDB($monograph->getDateSubmitted()), $this->datetimeToDB($monograph->getDateStatusModified()), $this->datetimeToDB($monograph->getLastModified())),
00194 array(
00195 $monograph->getLocale(),
00196 (int) $monograph->getUserId(),
00197 (int) $monograph->getPressId(),
00198 (int) $monograph->getSeriesId(),
00199 $monograph->getSeriesPosition(),
00200 $monograph->getLanguage(),
00201 $monograph->getCommentsToEditor(),
00202 $monograph->getStatus() === null ? STATUS_QUEUED : (int) $monograph->getStatus(),
00203 $monograph->getSubmissionProgress() === null ? 1 : (int) $monograph->getSubmissionProgress(),
00204 $monograph->getStageId() === null ? 1 : (int) $monograph->getStageId(),
00205 $monograph->getPages(),
00206 (int) $monograph->getHideAuthor(),
00207 (int) $monograph->getCommentsStatus(),
00208 (int) $monograph->getWorkType(),
00209 )
00210 );
00211
00212 $monograph->setId($this->getInsertMonographId());
00213 $this->updateLocaleFields($monograph);
00214
00215 return $monograph->getId();
00216 }
00217
00222 function updateMonograph($monograph) {
00223 $this->update(
00224 sprintf('UPDATE monographs
00225 SET user_id = ?,
00226 series_id = ?,
00227 series_position = ?,
00228 language = ?,
00229 comments_to_ed = ?,
00230 date_submitted = %s,
00231 date_status_modified = %s,
00232 last_modified = %s,
00233 status = ?,
00234 press_id = ?,
00235 submission_progress = ?,
00236 stage_id = ?,
00237 edited_volume = ?,
00238 hide_author = ?
00239
00240 WHERE monograph_id = ?',
00241 $this->datetimeToDB($monograph->getDateSubmitted()), $this->datetimeToDB($monograph->getDateStatusModified()), $this->datetimeToDB($monograph->getLastModified())),
00242 array(
00243 (int) $monograph->getUserId(),
00244 (int) $monograph->getSeriesId(),
00245 $monograph->getSeriesPosition(),
00246 $monograph->getLanguage(),
00247 $monograph->getCommentsToEditor(),
00248 (int) $monograph->getStatus(),
00249 (int) $monograph->getPressId(),
00250 (int) $monograph->getSubmissionProgress(),
00251 (int) $monograph->getStageId(),
00252 (int) $monograph->getWorkType(),
00253 (int) $monograph->getHideAuthor(),
00254 (int) $monograph->getId()
00255 )
00256 );
00257 $this->updateLocaleFields($monograph);
00258 $this->flushCache();
00259 }
00260
00265 function deleteObject(&$monograph) {
00266 return $this->deleteById($monograph->getId());
00267 }
00268
00273 function deleteById($monographId) {
00274 $this->authorDao->deleteAuthorsByMonograph($monographId);
00275
00276 $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO');
00277 $seriesEditorSubmissionDao->deleteDecisionsByMonograph($monographId);
00278 $seriesEditorSubmissionDao->deleteReviewRoundsByMonograph($monographId);
00279
00280 $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00281 $reviewAssignmentDao->deleteBySubmissionId($monographId);
00282
00283
00284 $chapterDao =& DAORegistry::getDAO('ChapterDAO');
00285 $chapters =& $chapterDao->getChapters($monographId);
00286 while ($chapter =& $chapters->next()) {
00287
00288 $chapterDao->deleteObject($chapter);
00289 }
00290
00291
00292 $monographKeywordDao =& DAORegistry::getDAO('MonographKeywordDAO');
00293 $monographKeywordVocab =& $monographKeywordDao->getBySymbolic(CONTROLLED_VOCAB_MONOGRAPH_KEYWORD, ASSOC_TYPE_MONOGRAPH, $monographId);
00294 if (isset($monographKeywordVocab)) {
00295 $monographKeywordDao->deleteObject($monographKeywordVocab);
00296 }
00297
00298 $monographDisciplineDao =& DAORegistry::getDAO('MonographDisciplineDAO');
00299 $monographDisciplineVocab =& $monographDisciplineDao->getBySymbolic(CONTROLLED_VOCAB_MONOGRAPH_DISCIPLINE, ASSOC_TYPE_MONOGRAPH, $monographId);
00300 if (isset($monographDisciplineVocab)) {
00301 $monographDisciplineDao->deleteObject($monographDisciplineVocab);
00302 }
00303
00304 $monographAgencyDao =& DAORegistry::getDAO('MonographAgencyDAO');
00305 $monographAgencyVocab =& $monographAgencyDao->getBySymbolic(CONTROLLED_VOCAB_MONOGRAPH_AGENCY, ASSOC_TYPE_MONOGRAPH, $monographId);
00306 if (isset($monographAgencyVocab)) {
00307 $monographAgencyDao->deleteObject($monographAgencyVocab);
00308 }
00309
00310 $monographLanguageDao =& DAORegistry::getDAO('MonographLanguageDAO');
00311 $monographLanguageVocab =& $monographLanguageDao->getBySymbolic(CONTROLLED_VOCAB_MONOGRAPH_LANGUAGE, ASSOC_TYPE_MONOGRAPH, $monographId);
00312 if (isset($monographLanguageVocab)) {
00313 $monographLanguageDao->deleteObject($monographLanguageVocab);
00314 }
00315
00316 $monographSubjectDao =& DAORegistry::getDAO('MonographSubjectDAO');
00317 $monographSubjectVocab =& $monographSubjectDao->getBySymbolic(CONTROLLED_VOCAB_MONOGRAPH_SUBJECT, ASSOC_TYPE_MONOGRAPH, $monographId);
00318 if (isset($monographSubjectVocab)) {
00319 $monographSubjectDao->deleteObject($monographSubjectVocab);
00320 }
00321
00322
00323 $signoffDao =& DAORegistry::getDAO('SignoffDAO');
00324 $monographFileSignoffDao =& DAORegistry::getDAO('MonographFileSignoffDAO');
00325
00326
00327 $monographFileSignoffs = $monographFileSignoffDao->getAllByMonograph($monographId);
00328 while ($signoff =& $monographFileSignoffs->next()) {
00329 $signoffDao->deleteObject($signoff);
00330 unset($signoff);
00331 }
00332
00333
00334 $monographSignoffs =& $signoffDao->getAllByAssocType(ASSOC_TYPE_MONOGRAPH, $monographId);
00335 while ($signoff =& $monographSignoffs->next()) {
00336 $signoffDao->deleteObject($signoff);
00337 unset($signoff);
00338 }
00339
00340
00341 $stageAssignmentDao =& DAORegistry::getDAO('StageAssignmentDAO');
00342 $stageAssignments =& $stageAssignmentDao->getBySubmissionAndStageId($monographId);
00343 while ($stageAssignment =& $stageAssignments->next()) {
00344 $stageAssignmentDao->deleteObject($stageAssignment);
00345 unset($stageAssignment);
00346 }
00347
00348
00349
00350 $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00351 $submissionFileDao->deleteAllRevisionsBySubmissionId($monographId);
00352
00353
00354 $monograph =& $this->getById($monographId);
00355 assert(is_a($monograph, 'Monograph'));
00356
00357 import('classes.file.MonographFileManager');
00358 $monographFileManager = new MonographFileManager($monograph->getPressId(), $monograph->getId());
00359 $monographFileManager->rmtree($monographFileManager->getBasePath());
00360
00361
00362 $monographCommentDao =& DAORegistry::getDAO('MonographCommentDAO');
00363 $monographCommentDao->deleteByMonographId($monographId);
00364
00365
00366 $featureDao =& DAORegistry::getDAO('FeatureDAO');
00367 $featureDao->deleteByMonographId($monographId);
00368
00369 $newReleaseDao =& DAORegistry::getDAO('NewReleaseDAO');
00370 $newReleaseDao->deleteByMonographId($monographId);
00371
00372
00373 $notificationDao =& DAORegistry::getDAO('NotificationDAO');
00374 $notificationDao->deleteByAssoc(ASSOC_TYPE_MONOGRAPH, $monographId);
00375
00376 $this->update('DELETE FROM monograph_settings WHERE monograph_id = ?', (int) $monographId);
00377 $this->update('DELETE FROM monographs WHERE monograph_id = ?', (int) $monographId);
00378 }
00379
00385 function &getByPressId($pressId) {
00386 $primaryLocale = AppLocale::getPrimaryLocale();
00387 $locale = AppLocale::getLocale();
00388
00389 $result =& $this->retrieve(
00390 'SELECT m.*, pm.date_published,
00391 COALESCE(stl.setting_value, stpl.setting_value) AS series_title,
00392 COALESCE(sal.setting_value, sapl.setting_value) AS series_abbrev
00393 FROM monographs m
00394 LEFT JOIN series s ON s.series_id = m.series_id
00395 LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?)
00396 LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?)
00397 LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?)
00398 LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?)
00399 LEFT JOIN published_monographs pm ON (m.monograph_id = pm.monograph_id)
00400 WHERE m.press_id = ?',
00401 array(
00402 'title', $primaryLocale,
00403 'title', $locale,
00404 'abbrev', $primaryLocale,
00405 'abbrev', $locale,
00406 (int) $pressId
00407 )
00408 );
00409
00410 $returner = new DAOResultFactory($result, $this, '_fromRow');
00411 return $returner;
00412 }
00413
00419 function &getUnpublishedMonographsByPressId($pressId) {
00420 $primaryLocale = AppLocale::getPrimaryLocale();
00421 $locale = AppLocale::getLocale();
00422
00423 $result =& $this->retrieve(
00424 'SELECT m.*, pm.date_published,
00425 COALESCE(stl.setting_value, stpl.setting_value) AS series_title,
00426 COALESCE(sal.setting_value, sapl.setting_value) AS series_abbrev
00427 FROM monographs m
00428 LEFT JOIN series s ON s.series_id = m.series_id
00429 LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?)
00430 LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?)
00431 LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?)
00432 LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?)
00433 LEFT JOIN published_monographs pm ON (m.monograph_id = pm.monograph_id)
00434 WHERE m.press_id = ? AND
00435 (pm.monograph_id IS NULL OR pm.date_published IS NULL) AND
00436 m.submission_progress = 0',
00437 array(
00438 'title', $primaryLocale,
00439 'title', $locale,
00440 'abbrev', $primaryLocale,
00441 'abbrev', $locale,
00442 (int) $pressId
00443 )
00444 );
00445
00446 $returner = new DAOResultFactory($result, $this, '_fromRow');
00447 return $returner;
00448 }
00449
00454 function deleteByPressId($pressId) {
00455 $monographs = $this->getByPressId($pressId);
00456 import('classes.search.MonographSearchIndex');
00457 while ($monograph =& $monographs->next()) {
00458 if ($monograph->getDatePublished()) {
00459 MonographSearchIndex::deleteTextIndex($monograph->getId());
00460 }
00461 $this->deleteById($monograph->getId());
00462 unset($monograph);
00463 }
00464 }
00465
00472 function &getByUserId($userId, $pressId = null) {
00473 $primaryLocale = AppLocale::getPrimaryLocale();
00474 $locale = AppLocale::getLocale();
00475 $params = array(
00476 'title', $primaryLocale,
00477 'title', $locale,
00478 'abbrev', $primaryLocale,
00479 'abbrev', $locale,
00480 (int) $userId
00481 );
00482 if ($pressId) $params[] = $pressId;
00483
00484 $result =& $this->retrieve(
00485 'SELECT m.*, pm.date_published,
00486 COALESCE(atl.setting_value, atpl.setting_value) AS series_title,
00487 COALESCE(aal.setting_value, aapl.setting_value) AS series_abbrev
00488 FROM monographs m
00489 LEFT JOIN series aa ON (aa.series_id = m.series_id)
00490 LEFT JOIN series_settings atpl ON (aa.series_id = atpl.series_id AND atpl.setting_name = ? AND atpl.locale = ?)
00491 LEFT JOIN series_settings atl ON (aa.series_id = atl.series_id AND atl.setting_name = ? AND atl.locale = ?)
00492 LEFT JOIN series_settings aapl ON (aa.series_id = aapl.series_id AND aapl.setting_name = ? AND aapl.locale = ?)
00493 LEFT JOIN series_settings aal ON (aa.series_id = aal.series_id AND aal.setting_name = ? AND aal.locale = ?)
00494 LEFT JOIN published_monographs pm ON (m.monograph_id = pm.monograph_id)
00495 WHERE m.user_id = ?' .
00496 (isset($pressId)?' AND m.press_id = ?':''),
00497 $params
00498 );
00499
00500 $returner = new DAOResultFactory($result, $this, '_fromRow');
00501 return $returner;
00502 }
00503
00508 function removeMonographsFromSeries($seriesId) {
00509 $this->update(
00510 'UPDATE monographs SET series_id = null WHERE series_id = ?',
00511 (int) $seriesId
00512 );
00513
00514 $this->flushCache();
00515 }
00516
00521 function getInsertMonographId() {
00522 return $this->getInsertId('monographs', 'monograph_id');
00523 }
00524
00528 function flushCache() {
00529
00530
00531 $cache =& $this->_getCache();
00532 $cache->flush();
00533 unset($cache);
00534
00535
00536 }
00537
00545 function &getMonographsBySeriesEditorId($pressId = null, $seriesEditorId = null) {
00546 $primaryLocale = AppLocale::getPrimaryLocale();
00547 $locale = AppLocale::getLocale();
00548
00549 $params = array(
00550 'title', $primaryLocale,
00551 'title', $locale,
00552 'abbrev', $primaryLocale,
00553 'abbrev', $locale,
00554 (int) ROLE_ID_PRESS_MANAGER
00555 );
00556 if ($seriesEditorId) $params[] = (int) $seriesEditorId;
00557 if ($pressId) $params[] = (int) $pressId;
00558
00559 $result =& $this->retrieve(
00560 'SELECT m.*
00561 FROM monographs m
00562 LEFT JOIN published_monographs pm ON m.monograph_id = pm.monograph_id
00563 LEFT JOIN series s ON s.series_id = m.series_id
00564 LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?)
00565 LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?)
00566 LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?)
00567 LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?)
00568 LEFT JOIN stage_assignments sa ON (m.monograph_id = sa.submission_id)
00569 LEFT JOIN user_groups g ON (sa.user_group_id = g.user_group_id AND g.role_id = ?)
00570 ' . ($seriesEditorId?' JOIN series_editors se ON (se.press_id = m.press_id AND se.user_id = ? AND se.series_id = m.series_id)':'') . '
00571 WHERE m.date_submitted IS NOT NULL
00572 ' . ($pressId?' AND m.press_id = ?':'') . '
00573 GROUP BY m.monograph_id',
00574 $params
00575 );
00576
00577 $returner = new DAOResultFactory($result, $this, '_fromRow');
00578 return $returner;
00579 }
00580
00586 function addCategory($monographId, $categoryId) {
00587 $this->update(
00588 'INSERT INTO monograph_categories
00589 (monograph_id, category_id)
00590 VALUES
00591 (?, ?)',
00592 array(
00593 (int) $monographId,
00594 (int) $categoryId
00595 )
00596 );
00597 }
00598
00604 function removeCategory($monographId, $categoryId) {
00605 $this->update(
00606 'DELETE FROM monograph_categories WHERE monograph_id = ? AND category_id = ?',
00607 array(
00608 (int) $monographId,
00609 (int) $categoryId
00610 )
00611 );
00612
00613
00614
00615 $newReleaseDao =& DAORegistry::getDAO('NewReleaseDAO');
00616 $newReleaseDao->deleteNewRelease($monographId, ASSOC_TYPE_CATEGORY, $categoryId);
00617
00618 $featureDao =& DAORegistry::getDAO('FeatureDAO');
00619 $featureDao->deleteFeature($monographId, ASSOC_TYPE_CATEGORY, $categoryId);
00620 }
00621
00626 function removeCategories($monographId) {
00627 $this->update(
00628 'DELETE FROM monograph_categories WHERE monograph_id = ?',
00629 (int) $monographId
00630 );
00631 }
00632
00638 function getCategories($monographId, $pressId = null) {
00639 $params = array((int) $monographId);
00640 if ($pressId) $params[] = (int) $pressId;
00641
00642 $categoryDao =& DAORegistry::getDAO('CategoryDAO');
00643 $result =& $this->retrieve(
00644 'SELECT c.*
00645 FROM categories c,
00646 monograph_categories mc,
00647 monographs m
00648 WHERE c.category_id = mc.category_id AND
00649 m.monograph_id = ? AND
00650 ' . ($pressId?' c.press_id = m.press_id AND m.press_id = ? AND':'') . '
00651 m.monograph_id = mc.monograph_id',
00652 $params
00653 );
00654
00655
00656 $returner = new DAOResultFactory($result, $categoryDao, '_fromRow');
00657 return $returner;
00658 }
00659
00665 function getUnassignedCategories($monographId, $pressId = null) {
00666 $params = array((int) $monographId);
00667 if ($pressId) $params[] = (int) $pressId;
00668
00669 $categoryDao =& DAORegistry::getDAO('CategoryDAO');
00670
00671
00672 $result =& $this->retrieve(
00673 'SELECT c.*
00674 FROM monographs m
00675 JOIN categories c ON (c.press_id = m.press_id)
00676 LEFT JOIN monograph_categories mc ON (m.monograph_id = mc.monograph_id AND mc.category_id = c.category_id)
00677 WHERE m.monograph_id = ? AND
00678 ' . ($pressId?' m.press_id = ? AND':'') . '
00679 mc.monograph_id IS NULL
00680 ORDER BY CASE WHEN c.parent_id = 0 THEN c.category_id * 2 ELSE (c.parent_id * 2) + 1 END ASC',
00681 $params
00682 );
00683
00684
00685 $returner = new DAOResultFactory($result, $categoryDao, '_fromRow');
00686 return $returner;
00687 }
00688
00695 function categoryAssociationExists($monographId, $categoryId) {
00696 $result =& $this->retrieve(
00697 'SELECT COUNT(*) FROM monograph_categories WHERE monograph_id = ? AND category_id = ?',
00698 array((int) $monographId, (int) $categoryId)
00699 );
00700 $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
00701
00702 $result->Close();
00703 unset($result);
00704
00705 return $returner;
00706 }
00707 }
00708
00709 ?>