CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MessageFactory.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: MessageFactory.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2011-2016 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
14 class MessageFactory extends ItemFactory
15 {
16 # ---- PUBLIC INTERFACE --------------------------------------------------
17
20
24 public function __construct()
25 {
26 parent::__construct("Message", "Messages", "MessageId", "Subject");
27 }
28
33
40 public function GetMessagesPostedByUser($UserId, $Count = NULL)
41 {
42 # retrieve message IDs posted by specified user
43 $Messages = array();
44 if (intval($Count) === 0) { return $Messages; }
45
46 $this->DB->Query("SELECT MessageId FROM Messages"
47 ." WHERE PosterId = ".intval($UserId)
48 ." ORDER BY DatePosted DESC"
49 .($Count ? " LIMIT ".intval($Count) : ""));
50 $MessageIds = $this->DB->FetchColumn("MessageId");
51
52 # load messages based on message IDs
53 foreach ($MessageIds as $Id)
54 {
55 $Messages[$Id] = new Message($Id);
56 }
57
58 # return array of message IDs to caller
59 return $Messages;
60 }
61
64 # ---- PRIVATE INTERFACE -------------------------------------------------
65 }
66
Message
Abstraction for forum messages and resource comments.
Definition: Message.php:14
MessageFactory\__construct
__construct()
Object constructor.
Definition: MessageFactory.php:24
PHP
PHP
Definition: RSSClient--Test.php:12
MessageFactory\GetMessagesPostedByUser
GetMessagesPostedByUser($UserId, $Count=NULL)
Get all messages posted by specified user, in reverse date order.
Definition: MessageFactory.php:40
ItemFactory
Common factory class for item manipulation.
Definition: ItemFactory.php:17
MessageFactory
Factory for forum messages / resource comments.
Definition: MessageFactory.php:14