00001 <?php
00002
00016 import('lib.pkp.classes.note.PKPNoteDAO');
00017 import('classes.note.Note');
00018
00019 class NoteDAO extends PKPNoteDAO {
00023 function NoteDAO() {
00024 parent::PKPNoteDAO();
00025 }
00026
00031 function newDataObject() {
00032 return new Note();
00033 }
00034
00038 function unreadNotesExistByAssoc($assocType, $assocId, $userId) {
00039 $params = array((int) $assocId, (int) $assocType);
00040 if (isset($userId)) $params[] = (int) $userId;
00041
00042 $result = $this->retrieve(
00043 'SELECT COUNT(*)
00044 FROM notes n
00045 LEFT JOIN item_views v ON (v.assoc_type = ? AND v.assoc_id = CAST(n.note_id AS CHAR) AND v.user_id = ?)
00046 WHERE n.assoc_type = ? AND
00047 n.assoc_id = ? AND
00048 v.assoc_id IS NULL',
00049 array(
00050 (int) ASSOC_TYPE_NOTE,
00051 (int) $userId,
00052 (int) $assocType,
00053 (int) $assocId
00054 )
00055 );
00056
00057 $returner = isset($result->fields[0]) && $result->fields[0] == 0 ? false : true;
00058 $result->Close();
00059
00060 return $returner;
00061 }
00062 }
00063
00064 ?>