|
CWIS Developer Documentation
|
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... | |
Represents a "resource" in CWIS.
Definition at line 13 of file Resource.php.
| Resource::Classifications | ( | ) |
Definition at line 1788 of file Resource.php.
References Id().
Referenced by Delete().

| Resource::Clear | ( | $Field, | |
$ValueToClear = NULL |
|||
| ) |
Definition at line 1494 of file Resource.php.
References Get(), Id(), IsTempResource(), 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.
Referenced by ClearByField().

| Resource::ClearByField | ( | $Field, | |
$ValueToClear = NULL |
|||
| ) |
Definition at line 1780 of file Resource.php.
References Clear().
Referenced by ClearByFieldId(), and Set().

| Resource::ClearByFieldId | ( | $FieldId, | |
$ValueToClear = NULL |
|||
| ) |
Definition at line 1487 of file Resource.php.
References ClearByField().
| Resource::Comments | ( | ) |
Definition at line 1945 of file Resource.php.
References Id().
|
static |
Create a new resource.
| int | $SchemaId | ID of metadata schema for new resource. |
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().

| Resource::CumulativeRating | ( | ) |
Definition at line 1817 of file Resource.php.
Referenced by GetAsArray(), NumberOfRatings(), Resource(), and ScaledCumulativeRating().

| Resource::Delete | ( | ) |
Remove resource (and accompanying associations) from database and delete any associated files.
Definition at line 139 of file Resource.php.
References Classifications(), and Id().
Referenced by CWUser\Delete().

| Resource::FieldIsSet | ( | $FieldNameOrObject, | |
$IgnorePadding = FALSE |
|||
| ) |
Determine if the value for a field is set.
| mixed | $FieldNameOrObject | Full name of field or a Field object. |
| bool | $IgnorePadding | Optional flag for ignoring whitespace padding for text, paragraph, number, and URL fields. |
Definition at line 896 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.
| mixed | $FieldNameOrObject | Full name of field or a Field object. |
| bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
| bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. |
Definition at line 344 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().

| Resource::GetAsArray | ( | $IncludeDisabledFields = FALSE, |
|
$ReturnObjects = TRUE |
|||
| ) |
Retrieve all resource values as an array.
| bool | $IncludeDisabledFields | Include values for disabled fields. (OPTIONAL, defaults to FALSE) |
| bool | $ReturnObjects | If TRUE, an object is returned for field types where appropriate, in the same fashion as Resource::Get() (OPTIONAL, defaults to TRUE) |
Definition at line 675 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().
Definition at line 640 of file Resource.php.
References Get().
| Resource::GetByFieldId | ( | $FieldId, | |
$ReturnObject = FALSE, |
|||
$IncludeVariants = FALSE |
|||
| ) |
Retrieve value using field ID.
| int | $FieldId | ID of field. |
| bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
| bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. |
Definition at line 657 of file Resource.php.
References Get().
Referenced by GetMapped().

| Resource::GetMapped | ( | $MappedName, | |
$ReturnObject = FALSE, |
|||
$IncludeVariants = FALSE |
|||
| ) |
Retrieve value using standard (mapped) field name.
| string | $MappedName | Standard field name. |
| bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
| bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. Defaults to FALSE. |
Definition at line 721 of file Resource.php.
References GetByFieldId().
| Resource::GetQualifier | ( | $FieldName, | |
$ReturnObject = TRUE |
|||
| ) |
Retrieve qualifier by field name.
| string | $FieldName | Full name of field. |
| bool | $ReturnObject | If TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE. |
Definition at line 737 of file Resource.php.
References GetQualifierByField().
| Resource::GetQualifierByField | ( | $Field, | |
$ReturnObject = TRUE |
|||
| ) |
Retrieve qualifier by Field object.
| MetadataField | $Field | Field object. |
| bool | $ReturnObject | If TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE. |
Definition at line 765 of file Resource.php.
References $Items, Get(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_OPTION, and MetadataSchema\MDFTYPE_TREE.
Referenced by GetAsArray(), GetQualifier(), and GetQualifierByFieldId().

| Resource::GetQualifierByFieldId | ( | $FieldId, | |
$ReturnObject = TRUE |
|||
| ) |
Retrieve qualifier by field ID.
| int | $FieldId | ID of field. |
| int | $ReturnObject | If TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE. |
Definition at line 751 of file Resource.php.
References GetQualifierByField().
| Resource::Id | ( | ) |
Retrieve numerical resource ID.
Definition at line 252 of file Resource.php.
Referenced by Classifications(), Clear(), Comments(), Create(), Delete(), Get(), GetAsArray(), IsTempResource(), NumberOfComments(), NumberOfRatings(), Rating(), Resource(), CWUser\ResourceId(), and Set().

| Resource::IsTempResource | ( | $NewSetting = NULL | ) |
Get/set whether resource is a temporary record.
| bool | $NewSetting | TRUE/FALSE setting for whether resource is temporary. (OPTIONAL) |
Definition at line 266 of file Resource.php.
References Id(), and SchemaId().
Referenced by Clear(), and Set().

| Resource::NumberOfComments | ( | ) |
Definition at line 1965 of file Resource.php.
References Id().
| Resource::NumberOfRatings | ( | ) |
Definition at line 1833 of file Resource.php.
References CumulativeRating(), and Id().
| Resource::Rating | ( | $NewRating = NULL, |
|
$UserId = NULL |
|||
| ) |
Definition at line 1858 of file Resource.php.
References Id().
| Resource::Resource | ( | $ResourceId | ) |
Object constructor for loading an existing resource.
(To create a new resource, use Resource::Create().)
| int | $ResourceId | ID of resource to load. |
Definition at line 23 of file Resource.php.
References CumulativeRating(), and Id().
Referenced by Create(), Get(), and Set().

| Resource::ScaledCumulativeRating | ( | ) |
Definition at line 1820 of file Resource.php.
References CumulativeRating().
| Resource::SchemaId | ( | ) |
Retrieve ID of schema for resource.
Definition at line 258 of file Resource.php.
Referenced by IsTempResource(), UserCanEdit(), and UserCanView().

| Resource::Set | ( | $FieldNameOrObject, | |
| $NewValue | |||
| ) |
Set value using field name or field object.
| mixed | $FieldNameOrObject | Field name or MetadataField object. |
| mixed | $NewValue | New value for field. |
Definition at line 965 of file Resource.php.
References Classification\CLASSSTAT_OK, ClearByField(), FileFactory\Copy(), Get(), Id(), IsTempResource(), 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, and Resource().
Referenced by Get(), CWUser\Set(), SetByField(), and SetByFieldId().

| Resource::SetByField | ( | $Field, | |
| $NewValue | |||
| ) |
Method replaced by Resource::Set(), preserved for backward compatibility.
Definition at line 1434 of file Resource.php.
References Set().
| Resource::SetByFieldId | ( | $FieldId, | |
| $NewValue | |||
| ) |
Definition at line 1437 of file Resource.php.
References Set().
| Resource::SetQualifier | ( | $FieldName, | |
| $NewValue | |||
| ) |
Definition at line 1444 of file Resource.php.
References SetQualifierByField().
| Resource::SetQualifierByField | ( | $Field, | |
| $NewValue | |||
| ) |
Definition at line 1458 of file Resource.php.
Referenced by SetQualifier(), and SetQualifierByFieldId().

| Resource::SetQualifierByFieldId | ( | $FieldId, | |
| $NewValue | |||
| ) |
Definition at line 1451 of file Resource.php.
References SetQualifierByField().
| Resource::Status | ( | ) |
Retrieve result of last operation if available.
Definition at line 246 of file Resource.php.
Referenced by UserCanView().

| Resource::UserCanAuthorField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to author specified metadata field.
Definition at line 2109 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.
| User | $User | user |
Definition at line 2023 of file Resource.php.
References SchemaId(), and UserCanView().
| Resource::UserCanEditField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to edit specified metadata field.
Definition at line 2165 of file Resource.php.
Referenced by UserCanViewField().

| 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.
| User | $User | user |
Definition at line 1993 of file Resource.php.
References SchemaId(), and Status().
Referenced by UserCanEdit().

| Resource::UserCanViewField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to view specified metadata field.
Definition at line 2056 of file Resource.php.
References UserCanEditField().