CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- 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-2017 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
13 class SavedSearchFactory extends ItemFactory
14 {
15
16 # ---- PUBLIC INTERFACE --------------------------------------------------
17
21 public function __construct()
22 {
23 # set up item factory base class
24 parent::__construct("SavedSearch", "SavedSearches", "SearchId", "SearchName");
25 }
26
33 public function GetSearchesForUser($UserId)
34 {
35 # return list of searches to caller
36 return $this->GetItems("UserId = ".intval($UserId));
37 }
38
44 public function GetSearchesDueToRun()
45 {
46 # retrieve searches with frequency/time values that indicate need to be run
47 return $this->GetItems(
48 "((Frequency = ".SavedSearch::SEARCHFREQ_HOURLY.")"
49 ." AND (DateLastRun < '"
50 .date("Y-m-d H:i:s", (strtotime("1 hour ago") + 15))."'))"
51 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_DAILY.")"
52 ." AND (DateLastRun < '"
53 .date("Y-m-d H:i:s", (strtotime("1 day ago") + 15))."'))"
54 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_WEEKLY.")"
55 ." AND (DateLastRun < '"
56 .date("Y-m-d H:i:s", (strtotime("1 week ago") + 15))."'))"
57 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_BIWEEKLY.")"
58 ." AND (DateLastRun < '"
59 .date("Y-m-d H:i:s", (strtotime("2 weeks ago") + 15))."'))"
60 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_MONTHLY.")"
61 ." AND (DateLastRun < '"
62 .date("Y-m-d H:i:s", (strtotime("1 month ago") + 15))."'))"
63 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_QUARTERLY.")"
64 ." AND (DateLastRun < '"
65 .date("Y-m-d H:i:s", (strtotime("3 months ago") + 15))."'))"
66 ." OR ((Frequency = ".SavedSearch::SEARCHFREQ_YEARLY.")"
67 ." AND (DateLastRun < '"
68 .date("Y-m-d H:i:s", (strtotime("1 year ago") + 15))."'))");
69 }
70
75 public function GetSearchUserCount()
76 {
77 return $this->DB->Query(
78 "SELECT COUNT(DISTINCT UserId) AS UserCount FROM SavedSearches",
79 "UserCount");
80 }
81
82
83 # ---- PRIVATE INTERFACE -------------------------------------------------
84 }
SavedSearchFactory\GetSearchesForUser
GetSearchesForUser($UserId)
Get all saved searches for a specified user.
Definition: SavedSearchFactory.php:33
SavedSearch\SEARCHFREQ_WEEKLY
const SEARCHFREQ_WEEKLY
Definition: SavedSearch.php:19
SavedSearchFactory\__construct
__construct()
Object constructor.
Definition: SavedSearchFactory.php:21
SavedSearchFactory
Factory for manipulating SavedSearch objects.
Definition: SavedSearchFactory.php:13
SavedSearch\SEARCHFREQ_DAILY
const SEARCHFREQ_DAILY
Definition: SavedSearch.php:18
SavedSearch\SEARCHFREQ_QUARTERLY
const SEARCHFREQ_QUARTERLY
Definition: SavedSearch.php:22
SavedSearch\SEARCHFREQ_YEARLY
const SEARCHFREQ_YEARLY
Definition: SavedSearch.php:23
SavedSearch\SEARCHFREQ_HOURLY
const SEARCHFREQ_HOURLY
Definition: SavedSearch.php:17
SavedSearch\SEARCHFREQ_BIWEEKLY
const SEARCHFREQ_BIWEEKLY
Definition: SavedSearch.php:20
PHP
PHP
Definition: RSSClient--Test.php:12
SavedSearch\SEARCHFREQ_MONTHLY
const SEARCHFREQ_MONTHLY
Definition: SavedSearch.php:21
SavedSearchFactory\GetSearchUserCount
GetSearchUserCount()
Get number of users with saved searches.
Definition: SavedSearchFactory.php:75
ItemFactory\GetItems
GetItems($SqlCondition=NULL)
Retrieve items.
Definition: ItemFactory.php:460
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:44