CWIS Developer Documentation
SPTUserFactory.php
Go to the documentation of this file.
1 <?PHP
2 
3 #
4 # FILE: SPTUserFactory.php
5 #
6 # Part of the Collection Workflow Integration System (CWIS)
7 # Copyright 2003-2012 Edward Almasy and Internet Scout
8 # http://scout.wisc.edu
9 #
10 
12 {
13  # ---- PUBLIC INTERFACE --------------------------------------------------
14 
21  public function GetTopContributors($Limit = 5)
22  {
23  # assume no users will be found
24  $Users = array();
25 
26  # fetch the top contributors
27  $DB = new Database();
28  $DB->Query("SELECT U.*"
29  ." FROM APUsers U, Resources R"
30  ." WHERE U.UserId = R.LastModifiedById"
31  ." GROUP BY R.LastModifiedById"
32  ." ORDER BY COUNT(*) DESC"
33  ." LIMIT ".intval($Limit));
34  $UserIds = $DB->FetchColumn("UserId");
35 
36  # for each user id found
37  foreach ($UserIds as $UserId)
38  {
39  $Users[$UserId] = new SPTUser($UserId);
40  }
41 
42  # return the newest users
43  return $Users;
44  }
45 
52  public function GetMostRecentContributors($Limit = 5)
53  {
54  # assume no users will be found
55  $Users = array();
56 
57  # fetch the top contributors
58  $DB = new Database();
59  $DB->Query("SELECT U.*"
60  ." FROM APUsers U, Resources R"
61  ." WHERE U.UserId = R.LastModifiedById"
62  ." GROUP BY U.UserId"
63  ." ORDER BY MAX(R.DateLastModified) DESC"
64  ." LIMIT ".intval($Limit));
65  $UserIds = $DB->FetchColumn("UserId");
66 
67  # for each user id found
68  foreach ($UserIds as $UserId)
69  {
70  $Users[$UserId] = new SPTUser($UserId);
71  }
72 
73  # return the newest users
74  return $Users;
75  }
76 
77  # ---- PRIVATE INTERFACE -------------------------------------------------
78 
79 }
80 
81 ?>