CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

- File List
- File Members

SavedSearchFactory.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: SavedSearchFactory.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2009-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
13 class SavedSearchFactory extends ItemFactory {
14
15 # ---- PUBLIC INTERFACE --------------------------------------------------
16
20 function __construct()
21 {
22 # set up item factory base class
23 $this->ItemFactory("SavedSearch", "SavedSearches", "SearchId", "SearchName");
24 }
25
32 function GetSearchesForUser($UserId)
33 {
34 # return list of searches to caller
35 return $this->GetItems("UserId = ".intval($UserId));
36 }
37
43 function GetSearchesDueToRun()
44 {
45 # retrieve searches with frequency/time values that indicate need to be run
46 return $this->GetItems(
47 "((Frequency = ".SavedSearch::SEARCHFREQ_HOURLY.")"
48 ." AND (DateLastRun < '"
49 .date("Y-m-d H:i:s", (strtotime("1 hour ago") + 15))."'))"
50 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_DAILY.")"
51 ." AND (DateLastRun < '"
52 .date("Y-m-d H:i:s", (strtotime("1 day ago") + 15))."'))"
53 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_WEEKLY.")"
54 ." AND (DateLastRun < '"
55 .date("Y-m-d H:i:s", (strtotime("1 week ago") + 15))."'))"
56 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_BIWEEKLY.")"
57 ." AND (DateLastRun < '"
58 .date("Y-m-d H:i:s", (strtotime("2 weeks ago") + 15))."'))"
59 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_MONTHLY.")"
60 ." AND (DateLastRun < '"
61 .date("Y-m-d H:i:s", (strtotime("1 month ago") + 15))."'))"
62 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_QUARTERLY.")"
63 ." AND (DateLastRun < '"
64 .date("Y-m-d H:i:s", (strtotime("3 months ago") + 15))."'))"
65 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_YEARLY.")"
66 ." AND (DateLastRun < '"
67 .date("Y-m-d H:i:s", (strtotime("1 year ago") + 15))."'))");
68 }
69
74 function GetSearchUserCount()
75 {
76 return $this->DB->Query(
77 "SELECT COUNT(DISTINCT UserId) AS UserCount FROM SavedSearches",
78 "UserCount");
79 }
80
81
82 # ---- PRIVATE INTERFACE -------------------------------------------------
83
84 }
85
SavedSearchFactory\GetSearchesForUser
GetSearchesForUser($UserId)
Get all saved searches for a specified user.
Definition: SavedSearchFactory.php:32
SavedSearch\SEARCHFREQ_WEEKLY
const SEARCHFREQ_WEEKLY
Definition: SavedSearch.php:27
SavedSearchFactory\__construct
__construct()
Object constructor.
Definition: SavedSearchFactory.php:20
SavedSearchFactory
Factory for manipulating SavedSearch objects.
Definition: SavedSearchFactory.php:13
SavedSearch\SEARCHFREQ_DAILY
const SEARCHFREQ_DAILY
Definition: SavedSearch.php:26
SavedSearch\SEARCHFREQ_QUARTERLY
const SEARCHFREQ_QUARTERLY
Definition: SavedSearch.php:30
SavedSearch\SEARCHFREQ_YEARLY
const SEARCHFREQ_YEARLY
Definition: SavedSearch.php:31
PHP
PHP
Definition: OAIClient.php:39
SavedSearch\SEARCHFREQ_HOURLY
const SEARCHFREQ_HOURLY
Definition: SavedSearch.php:25
SavedSearch\SEARCHFREQ_BIWEEKLY
const SEARCHFREQ_BIWEEKLY
Definition: SavedSearch.php:28
SavedSearch\SEARCHFREQ_MONTHLY
const SEARCHFREQ_MONTHLY
Definition: SavedSearch.php:29
SavedSearchFactory\GetSearchUserCount
GetSearchUserCount()
Get number of users with saved searches.
Definition: SavedSearchFactory.php:74
ItemFactory\GetItems
GetItems($SqlCondition=NULL)
Retrieve items.
Definition: ItemFactory.php:565
ItemFactory
Common factory class for item manipulation.
Definition: ItemFactory.php:17
SavedSearchFactory\GetSearchesDueToRun
GetSearchesDueToRun()
Get all searches that should be run according to frequency and last run time.
Definition: SavedSearchFactory.php:43
ItemFactory\ItemFactory
ItemFactory($ItemClassName, $ItemTableName, $ItemIdFieldName, $ItemNameFieldName=NULL, $OrderOpsAllowed=FALSE, $SqlCondition=NULL)
Class constructor.
Definition: ItemFactory.php:36