Search:

# CWIS Developers Documentation

- Main Page
- Classes
- Files

- Search for |

- File List
- File Members

# SPTUserFactory.php

Go to the documentation of this file.

    00001 <?PHP
    00002
    00003 #
    00004 #   FILE:  SPTUserFactory.php
    00005 #
    00006 #   Part of the Scout Portal Toolkit
    00007 #   Copyright 2003 Internet Scout Project
    00008 #   http://scout.wisc.edu
    00009 #
    00010
    00011 class SPTUserFactory extends UserFactory
    00012 {
    00013
    00014     # ---- PUBLIC INTERFACE --------------------------------------------------
    00015
    00019     public function __construct()
    00020     {
    00021         global $Session;
    00022
    00023         # create database handle for parent and local use
    00024         $this->DB = new SPTDatabase();
    00025
    00026         # call parent constructor with the global or our own session
    00027         parent::__construct((isset($Session)) ? $Session : new Session($this->DB));
    00028     }
    00029
    00036     public function GetTopContributors($Limit = 5)
    00037     {
    00038         # assume no users will be found
    00039         $Users = array();
    00040
    00041         # fetch the top contributors
    00042         $this->DB->Query("SELECT U.*"
    00043                 ." FROM APUsers U, Resources R"
    00044                 ." WHERE U.UserId = R.LastModifiedById"
    00045                 ." GROUP BY R.LastModifiedById"
    00046                 ." ORDER BY COUNT(*) DESC"
    00047                 ." LIMIT ".intval($Limit));
    00048         $UserIds = $this->DB->FetchColumn("UserId");
    00049
    00050         # for each user id found
    00051         foreach ($UserIds as $UserId)
    00052         {
    00053             $Users[$UserId] = new SPTUser($UserId);
    00054         }
    00055
    00056         # return the newest users
    00057         return $Users;
    00058     }
    00059
    00066     public function GetMostRecentContributors($Limit = 5)
    00067     {
    00068         # assume no users will be found
    00069         $Users = array();
    00070
    00071         # fetch the top contributors
    00072         $this->DB->Query("SELECT U.*"
    00073                 ." FROM APUsers U, Resources R"
    00074                 ." WHERE U.UserId = R.LastModifiedById"
    00075                 ." GROUP BY U.UserId"
    00076                 ." ORDER BY MAX(R.DateLastModified) DESC"
    00077                 ." LIMIT ".intval($Limit));
    00078         $UserIds = $this->DB->FetchColumn("UserId");
    00079
    00080         # for each user id found
    00081         foreach ($UserIds as $UserId)
    00082         {
    00083             $Users[$UserId] = new SPTUser($UserId);
    00084         }
    00085
    00086         # return the newest users
    00087         return $Users;
    00088     }
    00089
    00090     # ---- PRIVATE INTERFACE -------------------------------------------------
    00091
    00092 }
    00093
    00094 ?>