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/ 16 # ---- PUBLIC INTERFACE -------------------------------------------------- 24 static $EmailWrapperSet = FALSE;
25 if (!$EmailWrapperSet)
28 $EmailWrapperSet = TRUE;
31 parent::__construct($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 61 if ($NewValue !== NULL)
64 "Attempt to set user privileges with CWUser::Privileges(), " 65 .
"which is no longer supported");
104 public function HasPriv($Privilege, $Privileges = NULL)
108 if ($Privileges instanceof
Resource)
110 return $Privilege->MeetsRequirements($this, $Privileges);
114 return $Privilege->MeetsRequirements($this);
119 return call_user_func_array(
"parent::HasPriv", func_get_args() );
133 public static function EmailWrapper($To, $Subject, $Message, $AdditionalHeaders)
135 # extract "From" address from supplied headers if available 136 if (strlen($AdditionalHeaders))
138 $HeaderLines = explode(
"\n", $AdditionalHeaders);
140 foreach ($HeaderLines as $Line)
142 $HeaderLine = trim($Line);
143 if (preg_match(
"/^from:/i", $Line))
145 $From = preg_replace(
"/^from:/i",
"", $Line);
149 $Headers[] = $HeaderLine;
156 if (isset($From)) { $Msg->From($From); }
158 $Msg->Subject($Subject);
159 $Msg->AddHeaders($Headers);
160 $Msg->Body($Message);
163 # report success to caller 173 static $CustomFields;
175 if (!isset($CustomFields))
177 $CustomFields = array();
180 foreach ($Schema->GetFields() as $Field)
182 # they're custom if not owned by CWIS 183 if ($Field->Owner() !=
"CWISCore")
185 $CustomFields[$Field->Id()] = $Field;
190 return $CustomFields;
199 static $DefaultFields;
201 if (!isset($DefaultFields))
203 $DefaultFields = array();
206 foreach ($Schema->GetFields() as $Field)
208 # they're default if owned by CWIS 209 if ($Field->Owner() ==
"CWISCore")
211 $DefaultFields[$Field->Id()] = $Field;
216 return $DefaultFields;
219 # ---- OVERRIDDEN METHODS ------------------------------------------------ 228 # delete the associated user resource if set 235 return parent::Delete();
244 public function Get($FieldName)
246 # provide backwards-compatibility for data migrated to users fields as 248 if (in_array($FieldName, self::$MigratedUserFields))
250 # return NULL if the resource object isn't set 256 # return the value from the associated resource 260 # otherwise, get it from the APUsers table 261 return parent::Get($FieldName);
270 public function Set($FieldName, $NewValue)
272 # provide backwards-compatibility for data migrated to users fields as 274 if (in_array($FieldName, self::$MigratedUserFields))
276 # set the value only if the resource object is set 284 # transform boolean values to 1 or 0 because that's what the User 286 if (is_bool($NewValue))
288 $NewValue = $NewValue ? 1 : 0;
291 # update the APUsers table 292 return parent::Set($FieldName, $NewValue);
295 # ---- PRIVATE INTERFACE ------------------------------------------------- 308 "RealName",
"WebSite",
"AddressLineOne",
"AddressLineTwo",
"City",
309 "State",
"ZipCode",
"Country");
319 if (self::$UserIdFieldId === NULL)
326 # couldn't get the user schema, which probably means CWIS hasn't 328 catch (Exception $Exception)
333 # the UserId field doesn't exist, which probably means CWIS hasn't been 335 if (!$Schema->FieldExists(
"UserId"))
340 # get matching resources, which should only be one 341 $Field = $Schema->GetFieldByName(
"UserId");
343 self::$UserIdFieldId = intval($Field->Id());
347 "SELECT ResourceId FROM ResourceUserInts WHERE ".
348 "FieldId=".self::$UserIdFieldId.
349 " AND UserId=".intval(
$UserId) );
350 $ResourceIds = $this->DB->FetchColumn(
"ResourceId");
351 $ResourceIdCount = count($ResourceIds);
354 if ($ResourceIdCount < 1)
359 # too many resources found 360 if ($ResourceIdCount > 1)
365 # construct the associated resource and return it 366 return new Resource(array_shift($ResourceIds));
375 # there must be a user ID, which is what the User class assumes, and the 376 # resource must be set 377 return isset($this->UserId) && isset($this->
Resource);
381 # ---- MAINTAINED FOR BACKWARD COMPATIBILITY IN INTERFACES (BEGIN) 383 # ---- user interface preference mnemonics 384 # color avoidance flags 394 # content display options 399 # content view options 404 # audio description options 409 # caption type options 416 # user interface / accessibility preferences 463 # ---- MAINTAINED FOR BACKWARD COMPATIBILITY IN INTERFACES (END) 465 private static $UserIdFieldId = NULL;
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)
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)
Get($Field, $ReturnObject=FALSE, $IncludeVariants=FALSE)
Retrieve value using field name or field object.
__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
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.
Set($Field, $NewValue, $Reset=FALSE)
Set value using field name or field object.
const UIPREF_AVOID_PURPLEGREY
const UIPREF_CONTENTDENSITY_OVERVIEW
GetResource()
Get the associated user resource for this user.
CWIS-specific user class.
Delete()
Remove resource (and accompanying associations) from database and delete any associated files...
PrefFontSize($NewValue=DB_NOVALUE)