Search:

# CWIS Developers Documentation

- Main Page
- Classes
- Files

- File List
- File Members

# MessageFactory.php

Go to the documentation of this file.

    00001 <?PHP
    00002
    00003 #
    00004 #   FILE:  MessageFactory.php
    00005 #
    00006 #   Part of the Collection Workflow Integration System
    00007 #   Copyright 2011 Edward Almasy and Internet Scout
    00008 #   http://scout.wisc.edu
    00009 #
    00010
    00016 class MessageFactory extends ItemFactory {
    00017
    00018     # ---- PUBLIC INTERFACE --------------------------------------------------
    00019
    00022
    00024     public function MessageFactory()
    00025     {
    00026         $this->ItemFactory("Message", "Messages", "MessageId", "Subject");
    00027     }
    00028
    00033
    00040     public function GetMessagesPostedByUser($UserId, $Count = NULL)
    00041     {
    00042         # retrieve message IDs posted by specified user
    00043         $this->DB->Query("SELECT MessageId FROM Messages"
    00044                 ." WHERE PosterId = ".intval($UserId)
    00045                 ." ORDER BY DatePosted DESC"
    00046                 .($Count ? " LIMIT ".intval($Count) : ""));
    00047         $MessageIds = $this->DB->FetchColumn("MessageId");
    00048
    00049         # load messages based on message IDs
    00050         $Messages = array();
    00051         foreach ($MessageIds as $Id)
    00052         {
    00053             $Messages[$Id] = new Message($Id);
    00054         }
    00055
    00056         # return array of message IDs to caller
    00057         return $Messages;
    00058     }
    00059
    00062     # ---- PRIVATE INTERFACE -------------------------------------------------
    00063
    00064 }