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 --------------------------------------------------
23 static $EmailWrapperSet = FALSE;
24 if (!$EmailWrapperSet)
27 $EmailWrapperSet = TRUE;
30 # call the parent constructor
31 parent::User($UserInfo);
33 # try to fetch the associated resource if the user was found
34 if ($this->Result ===
U_OKAY)
38 # the associated resource was successfully found
44 # there was a problem finding the resource
59 if ($NewValue !== NULL)
62 "Attempt to set user privileges with CWUser::Privileges(), "
63 .
"which is no longer supported");
102 public function HasPriv($Privilege, $Privileges = NULL)
106 if ($Privileges instanceof
Resource)
108 return $Privilege->MeetsRequirements($this, $Privileges);
112 return $Privilege->MeetsRequirements($this);
117 return call_user_func_array(
"parent::HasPriv", func_get_args() );
131 public static function EmailWrapper($To, $Subject, $Message, $AdditionalHeaders)
133 # extract "From" address from supplied headers if available
134 if (strlen($AdditionalHeaders))
136 $HeaderLines = explode(
"\n", $AdditionalHeaders);
138 foreach ($HeaderLines as $Line)
140 $HeaderLine = trim($Line);
141 if (preg_match(
"/^from:/i", $Line))
143 $From = preg_replace(
"/^from:/i",
"", $Line);
147 $Headers[] = $HeaderLine;
154 if (isset($From)) { $Msg->From($From); }
156 $Msg->Subject($Subject);
157 $Msg->AddHeaders($Headers);
158 $Msg->Body($Message);
161 # report success to caller
171 static $CustomFields;
173 if (!isset($CustomFields))
175 $CustomFields = array();
178 foreach ($Schema->GetFields() as $Field)
180 # they're custom if not owned by CWIS
181 if ($Field->Owner() !=
"CWISCore")
183 $CustomFields[$Field->Id()] = $Field;
188 return $CustomFields;
197 static $DefaultFields;
199 if (!isset($DefaultFields))
201 $DefaultFields = array();
204 foreach ($Schema->GetFields() as $Field)
206 # they're default if owned by CWIS
207 if ($Field->Owner() ==
"CWISCore")
209 $DefaultFields[$Field->Id()] = $Field;
214 return $DefaultFields;
217 # ---- OVERRIDDEN METHODS ------------------------------------------------
226 # delete the associated user resource if set
233 return parent::Delete();
242 public function Get($FieldName)
244 # provide backwards-compatibility for data migrated to users fields as
246 if (in_array($FieldName, self::$MigratedUserFields))
248 # return NULL if the resource object isn't set
254 # return the value from the associated resource
258 # otherwise, get it from the APUsers table
259 return parent::Get($FieldName);
268 public function Set($FieldName, $NewValue)
270 # provide backwards-compatibility for data migrated to users fields as
272 if (in_array($FieldName, self::$MigratedUserFields))
274 # set the value only if the resource object is set
282 # transform boolean values to 1 or 0 because that's what the User
284 if (is_bool($NewValue))
286 $NewValue = $NewValue ? 1 : 0;
289 # update the APUsers table
290 return parent::Set($FieldName, $NewValue);
293 # ---- PRIVATE INTERFACE -------------------------------------------------
306 "RealName",
"WebSite",
"AddressLineOne",
"AddressLineTwo",
"City",
307 "State",
"ZipCode",
"Country");
323 # couldn't get the factory or schema, which probably means CWIS hasn't
325 catch (Exception $Exception)
330 # the UserId field doesn't exist, which probably means CWIS hasn't been
332 if (!$Schema->FieldExists(
"UserId"))
337 # get matching resources, which should only be one
338 $Field = $Schema->GetFieldByName(
"UserId");
339 $ResourceIds = $Factory->GetItemIds(
"`".$Field->DBFieldName()
341 $ResourceIdCount = count($ResourceIds);
344 if ($ResourceIdCount < 1)
349 # too many resources found
350 if ($ResourceIdCount > 1)
355 # construct the associated resource and return it
356 return new Resource(array_shift($ResourceIds));
365 # there must be a user ID, which is what the User class assumes, and the
366 # resource must be set
367 return isset($this->UserId) && isset($this->
Resource);
371 # ---- MAINTAINED FOR BACKWARD COMPATIBILITY IN INTERFACES (BEGIN)
373 # ---- user interface preference mnemonics
374 # color avoidance flags
384 # content display options
389 # content view options
394 # audio description options
399 # caption type options
404 # user interface / accessibility preferences
421 # ---- MAINTAINED FOR BACKWARD COMPATIBILITY IN INTERFACES (END)
PrefFontTypeFace($NewValue=DB_NOVALUE)
PrefUseGraphicAlternatives($NewValue=DB_NOVALUE)
const UIPREF_AVOID_ORANGE
PrefCaptionType($NewValue=DB_NOVALUE)
Set($FieldName, $NewValue)
Set a value for the specified field.
const UIPREF_AVOID_BLUEYELLOW
const UIPREF_CONTENTVIEW_TEXTINTENSIVE
const UIPREF_AVOID_REDBLACK
PrefImageDescriptionLanguage($NewValue=DB_NOVALUE)
$Resource
The user resource associated with the user or NULL if the user isn't logged in.
Privileges(PrivilegeSet $NewValue=NULL)
THIS FUNCTION HAS BEEN DEPRECATED This provides compatibility for interfaces written to use a version...
ResourceId()
Get the ID of the user resource associated with the user.
const UIPREF_AVOID_REDGREEN
Delete()
Delete the user and its associated user resource.
const UIPREF_AVOID_GREENYELLOW
const UIPREF_AUDIODESCRIPTION_NONE
const UIPREF_CAPTIONTYPE_REDUCEDREADINGLEVEL
PrefCaptionRate($NewValue=DB_NOVALUE)
Set($FieldNameOrObject, $NewValue, $Reset=FALSE)
Set value using field name or field object.
PrefBackgroundColor($NewValue=DB_NOVALUE)
Id()
Retrieve numerical resource ID.
PrefSignLanguage($NewValue=DB_NOVALUE)
FetchAssociatedResource($UserId)
Fetch the associated user resource based off of a user ID.
IsResourceObjectSet()
Determine if the resource object for this object is set.
const UIPREF_AVOID_USEMAXMONOCHR
const UIPREF_CONTENTDENSITY_NOPREFERENCE
HasPriv($Privilege, $Privileges=NULL)
Determine if a user has a given privilege, or satisfies the conditions specified by a given privilege...
const UIPREF_AUDIODESCRIPTION_STANDARD
Get($FieldName)
Get a value from the specified field.
PrefAudioDescriptionLanguage($NewValue=DB_NOVALUE)
const UIPREF_CONTENTDENSITY_DETAILED
const UIPREF_CONTENTVIEW_NOPREFERENCE
PrefContentView($NewValue=DB_NOVALUE)
Set of privileges used to access resource information or other parts of the system.
PrefContentDensity($NewValue=DB_NOVALUE)
PrefFontColor($NewValue=DB_NOVALUE)
PrefColorAvoidanceFlags($NewValue=DB_NOVALUE)
__construct($UserInfo=NULL)
Load user data from the given user info or from the session if available.
const UIPREF_CAPTIONTYPE_VERBATIM
PrefVisualDescriptionLanguage($NewValue=DB_NOVALUE)
static EmailWrapper($To, $Subject, $Message, $AdditionalHeaders)
Adapter method to bridge between AxisPHP User class and ScoutLib Email class.
static SetEmailFunction($NewValue)
Set email function to use instead of mail().
const UIPREF_CONTENTVIEW_IMAGEINTENSIVE
Get($FieldNameOrObject, $ReturnObject=FALSE, $IncludeVariants=FALSE)
Retrieve value using field name or field object.
PrefAudioDescriptionLevel($NewValue=DB_NOVALUE)
Compatibility layer allowing interfaces built against the privilege system from CWIS 3...
static $MigratedUserFields
Fields that were previously part of the APUsers table that have been migrated to the Resources table ...
Represents a "resource" in CWIS.
static GetDefaultUserFields()
Get the default user fields.
const UIPREF_AUDIODESCRIPTION_EXPANDED
const UIPREF_CAPTIONTYPE_NONE
static GetCustomUserFields()
Get all custom user fields.
const UIPREF_AVOID_PURPLEGREY
const UIPREF_CONTENTDENSITY_OVERVIEW
GetResource()
Get the associated user resource for this user.
Factory for Resource objects.
CWIS-specific user class.
Delete()
Remove resource (and accompanying associations) from database and delete any associated files...
PrefFontSize($NewValue=DB_NOVALUE)