4 # FILE: SavedSearchFactory.php
6 # Part of the Collection Workflow Integration System
7 # Copyright 2009 Edward Almasy and Internet Scout
8 # http://scout.wisc.edu
16 # ---- PUBLIC INTERFACE --------------------------------------------------
21 # set up item factory base class
22 $this->
ItemFactory(
"SavedSearch",
"SavedSearches",
"SearchId",
"SearchName");
27 # start with empty list of searches
30 # retrieve all IDs for user
31 $this->DB->Query(
"SELECT SearchId FROM SavedSearches WHERE UserId = '"
32 .intval($UserId).
"'");
33 $SearchIds = $this->DB->FetchColumn(
"SearchId");
36 foreach ($SearchIds as $SearchId)
42 # return list of searches to caller
46 # retrieve all searches that should be run according to frequency and last run time
49 # start with empty list of searches
52 # retrieve searches with frequency/time values that indicate need to be run
53 $this->DB->Query(
"SELECT SearchId FROM SavedSearches"
55 .
" AND (DateLastRun < '"
56 .date(
"Y-m-d H:i:s", (strtotime(
"1 hour ago") + 15)).
"'))"
58 .
" AND (DateLastRun < '"
59 .date(
"Y-m-d H:i:s", (strtotime(
"1 day ago") + 15)).
"'))"
61 .
" AND (DateLastRun < '"
62 .date(
"Y-m-d H:i:s", (strtotime(
"1 week ago") + 15)).
"'))"
64 .
" AND (DateLastRun < '"
65 .date(
"Y-m-d H:i:s", (strtotime(
"2 weeks ago") + 15)).
"'))"
67 .
" AND (DateLastRun < '"
68 .date(
"Y-m-d H:i:s", (strtotime(
"1 month ago") + 15)).
"'))"
70 .
" AND (DateLastRun < '"
71 .date(
"Y-m-d H:i:s", (strtotime(
"3 months ago") + 15)).
"'))"
73 .
" AND (DateLastRun < '"
74 .date(
"Y-m-d H:i:s", (strtotime(
"1 year ago") + 15)).
"'))");
75 $SearchIds = $this->DB->FetchColumn(
"SearchId");
78 foreach ($SearchIds as $SearchId)
84 # return list of searches to caller
90 return $this->DB->Query(
91 "SELECT COUNT(*) AS SearchCount FROM SavedSearches",
"SearchCount");
96 return $this->DB->Query(
97 "SELECT COUNT(DISTINCT UserId) AS UserCount FROM SavedSearches",
102 # ---- PRIVATE INTERFACE -------------------------------------------------