Class CIB_DB

Description

CIB Core Module Database API.

This class presents a OOP interface to the common queries needed by CIB Core functionality.

  • todo: Further tease out SQL to the PhraseBook. The CIB_DB class should evolve into the functional API -- it needs more parameter checking and more consistency of return values to be useful. The places where a SQL statement was wrapped up for use here, but is only used by a single location in the code, might get "demoted" to pure PhraseBook status, etc.

Located in /include/classes/database/CIB_DB.inc (line 24)

DB
   |
   --CIB_DB
Direct descendents
Class Description
 class PS_DB PrepStep Module Database API.
 class ResultsDB Result Tracker Module Database API.
 class Team_DB Team Module Database API.
Method Summary
 CIB_DB CIB_DB (string $dbname, string $user, mixed $pass, string $password)
 void addPending (string $username, array $key)
 boolean availibleUserName (string $username)
 void denyPermissionToUser (int $permid, string $username)
 array expandTeamNamesFromID (array $keys)
 array getApprovedOutsideComps ([mixed $limit = ""], [mixed $offset = ""])
 array getCaptainsEmails (string $type, string $level)
 array getCibServers ([boolean $excludeSelf = TRUE], [mixed $limit = ""], [mixed $offset = ""])
 array getClosedComps ()
 array getCompAnnouncements ([int $limit = -1], int $offset)
 array getCompsByDate (string $start, string $end)
 array getCompTypes ()
 array getCompUnixNames ()
 array getConfigComps (User $user)
 array getDocumentList ([mixed $type = ""])
 array getHostedComps ([string $status = ""], [string $order = "getfirstdate"], [mixed $limit = ""], [mixed $offset = ""])
 array getPendingKey (int $permid)
 array getPendingKeys (string $userid)
 array getPendingPermissions (User $user)
 array getSiteAnnouncements ([int $limit = -1], int $offset)
 array getSyncRequests (User $user)
 array getTeamAdmin (User $user)
 array getTeamIDs ()
 array getTeamMemberships (User $user)
 array getTeamRequests (User $user)
 array getTeams ()
 string getUserPasswordByName (string $username)
 array getUserRoles ([string $type = "comp"])
 void grantPermissionToUser (int $permid, string $username)
Variables

Inherited Variables

Inherited from DB

DB::$db
DB::$dbname
DB::$lastOID
DB::$password
DB::$user
Methods
Constructor CIB_DB (line 37)

CIB_DB Constructor.

Simply call the parent constructor.

  • access: public
  • todo: Add a check after connecting to make sure its a central DB and not a per-comp DB
CIB_DB CIB_DB (string $dbname, string $user, mixed $pass, string $password)
  • string $dbname: what database do you want to connect to
  • string $user: as what user
  • string $password: which what password
addPending (line 1121)

Adds a user request for increased permissions

  • access: public
  • todo: elevate keys to class status throughout
void addPending (string $username, array $key)
  • string $username: the user requesting permission elevation
  • array $key: array with details about the request
availibleUserName (line 1143)

Check if a given username is available

  • return: true if name is available for use, FALSE otherwise
  • todo: fix typo here and in calling location(s)
  • access: public
boolean availibleUserName (string $username)
  • string $username: the name to test for prior existence
denyPermissionToUser (line 1047)

Deny a pending permission request and notify user.

Deletes the pending permission request and emails the user.

  • access: public
  • todo: Refactor to one of the Access Control Classes or new
void denyPermissionToUser (int $permid, string $username)
  • int $permid: the row identifier of the permission to deny
  • string $username: the unlucky user
expandTeamNamesFromID (line 576)

Update Keys to include TeamNames.

Adds a team name to each Team Key in the list of $keys

  • return: array of augmented keys
  • access: public
  • todo: refactor keys
array expandTeamNamesFromID (array $keys)
  • array $keys: standard key array items
getApprovedOutsideComps (line 431)

Return a list of approved non-hosted competitions.

  • return: of arrays, each subitem is structured as:
    • "Link" : CompURL
    • "Label" : Comp Full Name
  • todo: examine deprecated status and remove?
  • deprecated: never used explicitly, getCompDates seems to have supplanted it
  • access: public
array getApprovedOutsideComps ([mixed $limit = ""], [mixed $offset = ""])
getCaptainsEmails (line 486)

List of email addresses Generates a list of email address for users meeting $type and $level requirements.

Most common usage is $type="Team", $level="Affiliation Captain/Owner"

  • return: array of strings, emails
  • access: public
  • todo: rename function and callers
array getCaptainsEmails (string $type, string $level)
  • string $type: -- Site, Comp, of Team
  • string $level: what level of user within the above categories
getCibServers (line 410)

List of other known CIB servers.

It was initially envisioned that each region of the country would have their own CIB server or that schools would want to run their own, etc. I won't call this deprecated, but its currently unsused.

  • return: of arrays,
    • "Link" : CIB Server URL
    • "Label" : HostName
array getCibServers ([boolean $excludeSelf = TRUE], [mixed $limit = ""], [mixed $offset = ""])
  • boolean $excludeSelf: default TRUE, include this server in the list?
  • mixed $limit: standard pagination controls, empty for no limit
  • mixed $offset: standard pagination controls, empty for no offset
getClosedComps (line 226)

Return a list of closed competitions hosted by this server Returns a list of closed, hosted competitions. This was needed because the general getHostedComps() couldn't get multiple statuses as once.

  • return: of arrays, each subitem is structured as:
    • "Link" : CompUnix
    • "Label" : Comp Full Name
  • todo: unify with getHostedComps()? allow offset/limit?
  • access: public
array getClosedComps ()
getCompAnnouncements (line 105)

Return a list of Competition Announcements.

Returns a a list of approved competition announcements, by default returns all the announcements, but a $limit can be provided with an optional offset for pagination of announcements.

  • return: A list of announcements each item in the list is a labeled associative array
    • "Title" : the title of the announcement
    • "Author" : the full name of the poster
    • "Date" : when this announcement was posted
    • "Body" : the contents of the announcemet
    • "CompUnix" : the label used for linking
    • "CompName" : the full name of the competition
  • access: public
array getCompAnnouncements ([int $limit = -1], int $offset)
  • int $limit: How many announcements to return, default of -1 for unlimited
  • int $offset: skip how many announcements, default 0 for none skipped
getCompsByDate (line 308)

Return a list of competition between a given date range

  • return: keyed by dates with events each date contains an array of hashed arrays each subitem is structured as:
    • "CompName"
    • "CompUnix"
  • access: public
array getCompsByDate (string $start, string $end)
  • string $start: textual date like "Mar 4, 2005" (short/long/numerical-hyphenated is fine)
  • string $end: textual date like "August 16, 2005" (short/long/numerical-hyphenated is fine)
getCompStatusChoices (line 461)

List of possible competitions status

  • return: array of strings labels for the pre-configured competition statuses
  • access: public
array getCompStatusChoices ()
getCompTypes (line 147)

Return an list of configured competition types

Returns the list of "competition types" such as "US Collegiate", "USA Dance, Inc","NDCA", etc. These categories are used for pre-configuring expected divisions in the Result Tracker and in PrepStep.

  • return: of strings
  • access: public
array getCompTypes ()
getCompUnixNames (line 514)

List of used CompUnix names

  • return: array of strings each an used CompUnix label
  • access: public
array getCompUnixNames ()
getConfigComps (line 278)

Return a list of competition's a user is configuring.

  • return: of arrays, each subitem is structured as:
    • "CompName"
    • "CompUnix"
  • todo: Consider replacing User $user with string $username?
  • todo: Unify with Link/Label return type, elevate to Class?
  • access: public
array getConfigComps (User $user)
  • User $user: the user to find the list of configuring competitions
getDocumentList (line 162)

Return an list of documents Designed for returning lists of HowTos's and Help docuemnts, currently unused and probably broken.

  • return: of arrays
  • access: public
  • todo: look over, purge?
array getDocumentList ([mixed $type = ""])
  • mixed $type: list of documents types of empty string for all??
getHostedComps (line 204)

Return a list of competitions being hosted by this server Returns a list of hosted competitions having a given $status, normally ordered by date (default value of $order) and a full unlimited/offset list.

  • return: of arrays, each subitem is structured as:
    • "Link" : CompUnix
    • "Label" : Comp Full Name
  • todo: Abstract away name of columns for ordering
  • todo: conver $limit to pure integer
  • todo: conver $offset to pure integer
  • access: public
array getHostedComps ([string $status = ""], [string $order = "getfirstdate"], [mixed $limit = ""], [mixed $offset = ""])
  • string $status: if non-empty, what status only to return (often used for OPEN or ARCHIVE
  • string $order: what column to sort on, currently requires a name of a database column (with optional ASC or DESC), defalts to order by date of the first day of competition, in increasing order
  • mixed $limit: emptyString, default for no limit, otherwise an integer
  • mixed $offset: emptyString, default for none, otherwise an integer
getNonApprovedOutsideComps (line 250)

Return a list of outside competition advertisements pending approval.

In order to help make CIB a "first stop" on a ballroom competitor's registration process, we want to provide calendar listings of non-hosted events. It also assists with organizer planning, etc. However, as non-users are allowed to post eveents, a more strict approval process was needed.

  • return: of arrays, each subitem is structured as:
    • "CompName"
    • "CompUnix"
    • "CompURL"
    • "CompDate"
  • access: public
array getNonApprovedOutsideComps ()
getPendingKey (line 963)

Retrieve key information from a row identifier

  • return: standard key format
  • access: public
  • todo: Refactor keys to a Key Class (StoredObject?)
array getPendingKey (int $permid)
  • int $permid: the row identifier of the permission
getPendingKeys (line 932)

Retrieve pending key information for a given user

  • return: of arrays in standard key format
  • access: public
  • todo: Refactor keys to a Key Class (StoredObject?)
  • todo: change parameter name to username
  • todo: Consider refactoring function to Access Control-LockSmith?
array getPendingKeys (string $userid)
  • string $userid: the USERNAME of the user to fetch pending keys
getPendingPermissions (line 1080)

Fetch the list of pending permission requests that $user may approve.

  • return: of arrays:
    • "Username" : the user requesting elevation
    • "PermID" : row identifier
    • "Key" : standard key array
  • access: public
  • todo: elevate keys to class status throughout
array getPendingPermissions (User $user)
  • User $user: the user to find handleable requests
getSiteAnnouncements (line 59)

Return a list of Site Level Announcements.

Returns a a list of site announcements, by default returns all the announcements, but a $limit can be provided with an optional offset for pagination of announcements.

  • return: A list of announcements each item in the list is a labeled associative array
    • "Title" : the title of the announcement
    • "Author" : the full name of the poster
    • "Date" : when this announcement was posted
    • "Body" : the contents of the announcemet
  • access: public
array getSiteAnnouncements ([int $limit = -1], int $offset)
  • int $limit: How many announcements to return, default of -1 for unlimited
  • int $offset: skip how many announcements, default 0 for none skipped
getSyncRequests (line 786)

Retrieve status of requests to sync records

If a user is created after his "person" is already in the database (normally because of imported results) the user can request a synchronization of his two identities. This function returns the status of such requests.

  • return: array of arrays "Self" -- Pending Requests
    • "PersonName" -- the non user identity
    • "PersonID" -- to corresponding pkey
    • "User" -- username
    • "Teams" -- CSL of team names that non-user belongs to
    • "Requested" -- date requests
    • "Emailed" -- date approval authority was emailed);
    "Requests" -- Requests this user can approve
    • "OtherPersonName" -- the non-user identity
    • "OtherPersonID" -- corresponding pkey
    • "User" -- requestor's username
    • "UserName" -- requestor's full name
    • "UserEmail" -- reqquestor's email
    • "Teams" -- CSL of teams that non-user belongs to
    • ""Requested" -- date requested
    "Admin" -- Requests that should be elevated to a site staffer
    • "OtherPersonName" -- the non-user identity
    • "OtherPersonID" -- corresponding pkey
    • "User" -- requestor's username
    • "UserName" -- requestor's full name
    • "UserEmail" -- reqquestor's email
    • "Teams" -- CSL of teams that non-user belongs to
    • ""Requested" -- date requested
  • access: public
  • todo: Consider refactoring function to Access Control
array getSyncRequests (User $user)
  • User $user: the user to look up requests for
getTeamAdmin (line 367)

Return a list of teams to which $user can administer.

  • return: of arrays, each subitem is structured as
    • TeamID : int Team's primary key used in virtual URLs
    • TeamName : string Full text name
  • todo: Consider replacing User $user with string $username?
  • access: public
array getTeamAdmin (User $user)
  • User $user: the user to find team adminstatability for
getTeamIDs (line 533)

List of used TeamIDs

  • return: array of int each an used TeamID
  • access: public
array getTeamIDs ()
getTeamMemberships (line 342)

Return a list of teams to which $user belongs.

  • return: of strings, each string a full text name of the team
  • todo: Consider replacing User $user with string $username?
  • access: public
array getTeamMemberships (User $user)
  • User $user: the user to find the team membership's of
getTeamRequests (line 629)

Retrieve status of requests for team membership Requests can go either way, a user can "petition" to join a team, requiring team admin approval, or a team admin can "invite" a user to join their team, pending user approval.

  • return: array of arrays "Self" -- Pending Petitions
    • "User" -- username
    • "Team" -- team name that user wants to join
    • "Requested" -- date requests
    • "Emailed" -- date approval authority was emailed
    "Outstanding-Invites" -- Invitations issued by $user that are outstanding
    • "User" -- username
    • "Team" -- team name that invited user
    • "Requested" -- date requests
    • "Emailed" -- date user was emailed
    "Invites" -- Invitation from a team that $user can accept
    • Team" -- what team
    • "TeamID" -- pkey
    • "Requested" -- date invited
    • "Requestor" -- username that issues the invite
    • "Name" -- full name of reqquestor
    "Requests" -- requests from non-member that $user can accept
    • "Team" -- which team (in case an admin is on multiple teams)
    • "TeamID" -- pkey
    • "Requested" -- date requested
    • "Requestor" -- username of petitioner
    • "Name" -- full name of petitioner
    • "Email" -- email addresss of petitioner
    "Admin" -- Requests that should be elevated to a site staffer
    • "Team" -- which team
    • "TeamID" -- pkey
    • "Requested" -- date requested
    • "Requestor" -- username of petitioner
    • "Name" -- full name of petitioner
    • "Email" -- email addresss of petitioner
  • access: public
  • todo: Consider refactoring function to Access Control
array getTeamRequests (User $user)
  • User $user: the user to look up requests for
getTeams (line 391)

List of all known teams

  • return: of arrays,
    • "Link" : TeamID
    • "Label" : TeamName
array getTeams ()

Redefined in descendants as:
getUserPasswordByName (line 449)

Get a user's hased password.

Why is this in this class. This should be in User.

  • return: a hashed password
  • todo: Remove if possible, relocated to User
  • access: public
string getUserPasswordByName (string $username)
  • string $username
getUserRoles (line 553)

List of user access levels

  • return: array of strings each a permission level
  • access: public
array getUserRoles ([string $type = "comp"])
  • string $type: "comp" or "team"
grantPermissionToUser (line 996)

Grat a pending permission request and notify user.

Inserts new permission, deletes the pending permission request, and emails the user.

  • access: public
  • todo: Refactor to one of the Access Control Classes or new
void grantPermissionToUser (int $permid, string $username)
  • int $permid: the row identifier of the permission to grant
  • string $username: the lucky user

Inherited Methods

Inherited From DB

 DB::DB()
 DB::commit()
 DB::getDBName()
 DB::getDBpass()
 DB::getDBuser()
 DB::getLastOID()
 DB::helper_limitOffset()
 DB::helper_queryToArray()
 DB::helper_queryToArrayCategories()
 DB::helper_queryToSimpleArray()
 DB::helper_singleValueQuery()
 DB::query()
 DB::rollback()
 DB::startTransaction()

Documentation generated on Tue, 25 Apr 2006 12:59:32 -0400 by phpDocumentor 1.3.0RC3