CWIS Developer Documentation
Public Member Functions | Static Public Member Functions | List of all members
Resource Class Reference

Represents a "resource" in CWIS. More...

Public Member Functions

 Resource ($ResourceId)
 Object constructor for loading an existing resource. More...
 
 Delete ()
 Remove resource (and accompanying associations) from database and delete any associated files. More...
 
 Status ()
 Retrieve result of last operation if available. More...
 
 Id ()
 Retrieve numerical resource ID. More...
 
 SchemaId ()
 Retrieve ID of schema for resource. More...
 
 IsTempResource ($NewSetting=NULL)
 Get/set whether resource is a temporary record. More...
 
 Get ($FieldNameOrObject, $ReturnObject=FALSE, $IncludeVariants=FALSE)
 Retrieve value using field name or field object. More...
 
 GetByField ($FieldNameOrObject, $ReturnObject=FALSE, $IncludeVariants=FALSE)
 Old method for retrieving values, deprecated in favor of Get(). More...
 
 GetByFieldId ($FieldId, $ReturnObject=FALSE, $IncludeVariants=FALSE)
 Retrieve value using field ID. More...
 
 GetAsArray ($IncludeDisabledFields=FALSE, $ReturnObjects=TRUE)
 Retrieve all resource values as an array. More...
 
 GetMapped ($MappedName, $ReturnObject=FALSE, $IncludeVariants=FALSE)
 Retrieve value using standard (mapped) field name. More...
 
 GetQualifier ($FieldName, $ReturnObject=TRUE)
 Retrieve qualifier by field name. More...
 
 GetQualifierByFieldId ($FieldId, $ReturnObject=TRUE)
 Retrieve qualifier by field ID. More...
 
 GetQualifierByField ($Field, $ReturnObject=TRUE)
 Retrieve qualifier by Field object. More...
 
 FieldIsSet ($FieldNameOrObject, $IgnorePadding=FALSE)
 Determine if the value for a field is set. More...
 
 Set ($FieldNameOrObject, $NewValue)
 Set value using field name or field object. More...
 
 SetByField ($Field, $NewValue)
 Method replaced by Resource::Set(), preserved for backward compatibility. More...
 
 SetByFieldId ($FieldId, $NewValue)
 
 SetQualifier ($FieldName, $NewValue)
 
 SetQualifierByFieldId ($FieldId, $NewValue)
 
 SetQualifierByField ($Field, $NewValue)
 
 ClearByFieldId ($FieldId, $ValueToClear=NULL)
 
 Clear ($Field, $ValueToClear=NULL)
 
 ClearByField ($Field, $ValueToClear=NULL)
 
 Classifications ()
 
 CumulativeRating ()
 
 ScaledCumulativeRating ()
 
 NumberOfRatings ()
 
 Rating ($NewRating=NULL, $UserId=NULL)
 
 Comments ()
 
 NumberOfComments ()
 
 UserCanView (User $User)
 Determine if the given user can view the resource, e.g., on the full record page. More...
 
 UserCanEdit ($User)
 Determine if the given user can edit the resource. More...
 
 UserCanViewField ($User, $FieldOrFieldName)
 Check whether user is allowed to view specified metadata field. More...
 
 UserCanAuthorField ($User, $FieldOrFieldName)
 Check whether user is allowed to author specified metadata field. More...
 
 UserCanEditField ($User, $FieldOrFieldName)
 Check whether user is allowed to edit specified metadata field. More...
 

Static Public Member Functions

static Create ($SchemaId)
 Create a new resource. More...
 

Detailed Description

Represents a "resource" in CWIS.

Definition at line 13 of file Resource.php.

Member Function Documentation

Resource::Classifications ( )

Definition at line 1791 of file Resource.php.

References Id().

Referenced by Delete().

Here is the caller graph for this function:

Resource::Clear (   $Field,
  $ValueToClear = NULL 
)
Resource::ClearByField (   $Field,
  $ValueToClear = NULL 
)

Definition at line 1783 of file Resource.php.

References Clear().

Referenced by ClearByFieldId(), and Set().

Here is the caller graph for this function:

Resource::ClearByFieldId (   $FieldId,
  $ValueToClear = NULL 
)

Definition at line 1490 of file Resource.php.

References ClearByField().

Resource::Comments ( )

Definition at line 1948 of file Resource.php.

References Id().

static Resource::Create (   $SchemaId)
static

Create a new resource.

Parameters
int$SchemaIdID of metadata schema for new resource.
Returns
object Resource object.

Definition at line 59 of file Resource.php.

References Id(), MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, Resource(), MetadataSchema\SCHEMAID_DEFAULT, and MetadataField\UPDATEMETHOD_ONRECORDCREATE.

Referenced by CWUserFactory\CreateNewUser(), and ResourceFactory\DuplicateResource().

Here is the caller graph for this function:

Resource::CumulativeRating ( )

Definition at line 1820 of file Resource.php.

Referenced by GetAsArray(), NumberOfRatings(), Resource(), and ScaledCumulativeRating().

Here is the caller graph for this function:

Resource::Delete ( )

Remove resource (and accompanying associations) from database and delete any associated files.

Definition at line 142 of file Resource.php.

References Classifications(), and Id().

Referenced by CWUser\Delete().

Here is the caller graph for this function:

Resource::FieldIsSet (   $FieldNameOrObject,
  $IgnorePadding = FALSE 
)

Determine if the value for a field is set.

Parameters
mixed$FieldNameOrObjectFull name of field or a Field object.
bool$IgnorePaddingOptional flag for ignoring whitespace padding for text, paragraph, number, and URL fields.
Returns
Returns TRUE if the value is set or FALSE otherwise.

Definition at line 899 of file Resource.php.

References Get(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FILE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_IMAGE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

Resource::Get (   $FieldNameOrObject,
  $ReturnObject = FALSE,
  $IncludeVariants = FALSE 
)

Retrieve value using field name or field object.

Parameters
mixed$FieldNameOrObjectFull name of field or a Field object.
bool$ReturnObjectFor field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE.
bool$IncludeVariantsIf TRUE, includes variants in return value. Only applicable for ControlledName fields.
Returns
Requested object(s) or value(s). Returns empty array (for field types that allow multiple values) or NULL (for field types that do not allow multiple values) if no values found. Returns NULL if field does not exist or was otherwise invalid.
See Also
Resource::GetByFieldId()

Definition at line 347 of file Resource.php.

References FileFactory\GetFilesForResource(), Id(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FILE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_IMAGE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, MetadataSchema\MDFTYPE_USER, Resource(), and Set().

Referenced by Clear(), FieldIsSet(), CWUser\Get(), GetAsArray(), GetByField(), GetByFieldId(), GetQualifierByField(), Set(), and UserCanAuthorField().

Here is the caller graph for this function:

Resource::GetAsArray (   $IncludeDisabledFields = FALSE,
  $ReturnObjects = TRUE 
)

Retrieve all resource values as an array.

Parameters
bool$IncludeDisabledFieldsInclude values for disabled fields. (OPTIONAL, defaults to FALSE)
bool$ReturnObjectsIf TRUE, an object is returned for field types where appropriate, in the same fashion as Resource::Get() (OPTIONAL, defaults to TRUE)
Returns
Array of values with field names for array indices. Qualifiers (where available) are returned with an index of the field name with " Qualifier" appended.
See Also
Resource::Get()

Definition at line 678 of file Resource.php.

References CumulativeRating(), Get(), GetQualifierByField(), and Id().

Resource::GetByField (   $FieldNameOrObject,
  $ReturnObject = FALSE,
  $IncludeVariants = FALSE 
)

Old method for retrieving values, deprecated in favor of Get().

See Also
Get

Definition at line 643 of file Resource.php.

References Get().

Resource::GetByFieldId (   $FieldId,
  $ReturnObject = FALSE,
  $IncludeVariants = FALSE 
)

Retrieve value using field ID.

Parameters
int$FieldIdID of field.
bool$ReturnObjectFor field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE.
bool$IncludeVariantsIf TRUE, includes variants in return value. Only applicable for ControlledName fields.
Returns
Requested object(s) or value(s). Returns empty array (for field types that allow multiple values) or NULL (for field types that do not allow multiple values) if no values found.
See Also
Resource::Get()

Definition at line 660 of file Resource.php.

References Get().

Referenced by GetMapped().

Here is the caller graph for this function:

Resource::GetMapped (   $MappedName,
  $ReturnObject = FALSE,
  $IncludeVariants = FALSE 
)

Retrieve value using standard (mapped) field name.

Parameters
string$MappedNameStandard field name.
bool$ReturnObjectFor field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE.
bool$IncludeVariantsIf TRUE, includes variants in return value. Only applicable for ControlledName fields. Defaults to FALSE.
Returns
Requested object(s) or value(s), or NULL if no mapping found. Returns empty array (for field types that allow multiple values) or NULL (for field types that do not allow multiple values) if no values found.
See Also
Resource::Get()

Definition at line 724 of file Resource.php.

References GetByFieldId().

Resource::GetQualifier (   $FieldName,
  $ReturnObject = TRUE 
)

Retrieve qualifier by field name.

Parameters
string$FieldNameFull name of field.
bool$ReturnObjectIf TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE.
Returns
Array of qualifiers if field supports qualifiers, or NULL if field does not support qualifiers.

Definition at line 740 of file Resource.php.

References GetQualifierByField().

Resource::GetQualifierByField (   $Field,
  $ReturnObject = TRUE 
)

Retrieve qualifier by Field object.

Parameters
MetadataField$FieldField object.
bool$ReturnObjectIf TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE.
Returns
Array of qualifiers if field supports qualifiers, or NULL if field does not support qualifiers or field is invalid.

Definition at line 768 of file Resource.php.

References $Items, Get(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_OPTION, and MetadataSchema\MDFTYPE_TREE.

Referenced by GetAsArray(), GetQualifier(), and GetQualifierByFieldId().

Here is the caller graph for this function:

Resource::GetQualifierByFieldId (   $FieldId,
  $ReturnObject = TRUE 
)

Retrieve qualifier by field ID.

Parameters
int$FieldIdID of field.
int$ReturnObjectIf TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE.
Returns
Array of qualifiers if field supports qualifiers, or NULL if field does not support qualifiers or field is invalid.

Definition at line 754 of file Resource.php.

References GetQualifierByField().

Resource::Id ( )

Retrieve numerical resource ID.

Returns
Resource ID.

Definition at line 255 of file Resource.php.

Referenced by Classifications(), Clear(), Comments(), Create(), Delete(), Get(), GetAsArray(), IsTempResource(), NumberOfComments(), NumberOfRatings(), Rating(), Resource(), CWUser\ResourceId(), and Set().

Here is the caller graph for this function:

Resource::IsTempResource (   $NewSetting = NULL)

Get/set whether resource is a temporary record.

Parameters
bool$NewSettingTRUE/FALSE setting for whether resource is temporary. (OPTIONAL)
Returns
TRUE if resource is temporary record, or FALSE otherwise.

Definition at line 269 of file Resource.php.

References Id(), and SchemaId().

Referenced by Clear(), and Set().

Here is the caller graph for this function:

Resource::NumberOfComments ( )

Definition at line 1968 of file Resource.php.

References Id().

Resource::NumberOfRatings ( )

Definition at line 1836 of file Resource.php.

References CumulativeRating(), and Id().

Resource::Rating (   $NewRating = NULL,
  $UserId = NULL 
)

Definition at line 1861 of file Resource.php.

References Id().

Resource::Resource (   $ResourceId)

Object constructor for loading an existing resource.

(To create a new resource, use Resource::Create().)

Parameters
int$ResourceIdID of resource to load.
See Also
Create()

Definition at line 23 of file Resource.php.

References CumulativeRating(), and Id().

Referenced by Create(), Get(), and Set().

Here is the caller graph for this function:

Resource::ScaledCumulativeRating ( )

Definition at line 1823 of file Resource.php.

References CumulativeRating().

Resource::SchemaId ( )

Retrieve ID of schema for resource.

Returns
int Schema ID.

Definition at line 261 of file Resource.php.

Referenced by IsTempResource(), UserCanEdit(), and UserCanView().

Here is the caller graph for this function:

Resource::Set (   $FieldNameOrObject,
  $NewValue 
)
Resource::SetByField (   $Field,
  $NewValue 
)

Method replaced by Resource::Set(), preserved for backward compatibility.

See Also
Resource::Set()

Definition at line 1437 of file Resource.php.

References Set().

Resource::SetByFieldId (   $FieldId,
  $NewValue 
)

Definition at line 1440 of file Resource.php.

References Set().

Resource::SetQualifier (   $FieldName,
  $NewValue 
)

Definition at line 1447 of file Resource.php.

References SetQualifierByField().

Resource::SetQualifierByField (   $Field,
  $NewValue 
)

Definition at line 1461 of file Resource.php.

Referenced by SetQualifier(), and SetQualifierByFieldId().

Here is the caller graph for this function:

Resource::SetQualifierByFieldId (   $FieldId,
  $NewValue 
)

Definition at line 1454 of file Resource.php.

References SetQualifierByField().

Resource::Status ( )

Retrieve result of last operation if available.

Returns
Result of last operation (if available).

Definition at line 249 of file Resource.php.

Referenced by UserCanView().

Here is the caller graph for this function:

Resource::UserCanAuthorField (   $User,
  $FieldOrFieldName 
)

Check whether user is allowed to author specified metadata field.

Parameters
User$UserUser to check.
mixed$FieldOrFieldNameField name or object.
Returns
TRUE if user can author field, otherwise FALSE.

Definition at line 2112 of file Resource.php.

References Get().

Resource::UserCanEdit (   $User)

Determine if the given user can edit the resource.

The result of this method can be modified via the EVENT_RESOURCE_EDIT_PERMISSION_CHECK event.

Parameters
User$Useruser
Returns
bool TRUE if the user can edit the resource and FALSE otherwise

Definition at line 2026 of file Resource.php.

References SchemaId(), and UserCanView().

Resource::UserCanEditField (   $User,
  $FieldOrFieldName 
)

Check whether user is allowed to edit specified metadata field.

Parameters
User$UserUser to check.
mixed$FieldOrFieldNameField name or object.
Returns
TRUE if user can edit field, otherwise FALSE.

Definition at line 2168 of file Resource.php.

Referenced by UserCanViewField().

Here is the caller graph for this function:

Resource::UserCanView ( User  $User)

Determine if the given user can view the resource, e.g., on the full record page.

The result of this method can be modified via the EVENT_RESOURCE_VIEW_PERMISSION_CHECK event.

Parameters
User$Useruser
Returns
bool TRUE if the user can view the resource and FALSE otherwise

Definition at line 1996 of file Resource.php.

References SchemaId(), and Status().

Referenced by UserCanEdit().

Here is the caller graph for this function:

Resource::UserCanViewField (   $User,
  $FieldOrFieldName 
)

Check whether user is allowed to view specified metadata field.

Parameters
User$UserUser to check.
mixed$FieldOrFieldNameField name or object.
Returns
TRUE if user can view field, otherwise FALSE.

Definition at line 2059 of file Resource.php.

References UserCanEditField().


The documentation for this class was generated from the following file: