3 # FILE: CWUserFactory.php
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
15 # ---- PUBLIC INTERFACE --------------------------------------------------
22 parent::UserFactory();
36 # assume no users will be found
39 # fetch the top contributors
40 $this->DB->Query(
"SELECT U.*"
41 .
" FROM APUsers U, Resources R"
42 .
" WHERE U.UserId = R.LastModifiedById"
43 .
" GROUP BY R.LastModifiedById"
44 .
" ORDER BY COUNT(*) DESC"
45 .
" LIMIT ".intval($Limit));
46 $UserIds = $this->DB->FetchColumn(
"UserId");
48 # for each user id found
49 foreach ($UserIds as $UserId)
51 $Users[$UserId] =
new CWUser($UserId);
54 # return the newest users
68 # assume no users will be found
71 # fetch the top contributors
72 $this->DB->Query(
"SELECT U.*"
73 .
" FROM APUsers U, Resources R"
74 .
" WHERE U.UserId = R.LastModifiedById"
76 .
" ORDER BY MAX(R.DateLastModified) DESC"
77 .
" LIMIT ".intval($Limit));
78 $UserIds = $this->DB->FetchColumn(
"UserId");
80 # for each user id found
81 foreach ($UserIds as $UserId)
83 $Users[$UserId] =
new CWUser($UserId);
86 # return the newest users
90 # ---- OVERRIDDEN METHODS ------------------------------------------------
105 $UserName, $Password, $PasswordAgain, $EMail, $EMailAgain,
106 $IgnoreErrorCodes = NULL)
108 # add the user to the APUsers table
109 $User = parent::CreateNewUser(
117 # user account creation did not succeed, so return the error codes
118 if (!($User instanceof
User))
123 # create the user resource
126 # set the user ID for the resource
127 $Resource->Set(
"UserId", $User->Id());
132 # update timestamps as required
133 foreach ($TimestampFields as $Field)
135 if ($Field->UpdateMethod()
138 $Resource->Set($Field,
"now");
142 # make the user resource permanent
143 $Resource->IsTempResource(FALSE);
145 # get the CWUser object for the user
146 $CWUser =
new CWUser(intval($User->Id()));
148 # couldn't get the CWUser object
149 if ($CWUser->Status() !=
U_OKAY)
151 return array($CWUser->Status());
154 # return new user object to caller
158 # ---- PRIVATE INTERFACE -------------------------------------------------
$ResourceFactory
The resource factory for user resources.
GetTopContributors($Limit=5)
Get a list of users sorted by how many resources they have added or edited, starting with those who h...
GetMostRecentContributors($Limit=5)
Get the users sorted by when they last added or edited a resource starting with those who added/edite...
CWIS-specific user factory class.
__construct()
Construct the user factory object.
CreateNewUser($UserName, $Password, $PasswordAgain, $EMail, $EMailAgain, $IgnoreErrorCodes=NULL)
Create a new user.
static Create($SchemaId)
Create a new resource.
Factory for Resource objects.
CWIS-specific user class.