|
CWIS Developer Documentation
|
Represents a "resource" in CWIS. More...
Public Member Functions | |
| __construct ($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, $Reset=FALSE) | |
| 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, $AllowHooksToModify=TRUE) | |
| 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... | |
| UserCanAuthor ($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... | |
| UserCanEditField ($User, $FieldOrFieldName) | |
| Check whether user is allowed to edit specified metadata field. More... | |
| UserCanAuthorField ($User, $FieldOrFieldName) | |
| Check whether user is allowed to author specified metadata field. More... | |
| UserCanModifyField ($User, $FieldOrFieldName) | |
| Check whether user is allowed to modify (Edit for perm resources, Author for temp) specified metadata field. More... | |
Static Public Member Functions | |
| static | Create ($SchemaId) |
| Create a new resource. More... | |
Protected Attributes | |
| $DB | |
Represents a "resource" in CWIS.
Definition at line 13 of file Resource.php.
| Resource::__construct | ( | $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().
| Resource::Classifications | ( | ) |
Definition at line 1881 of file Resource.php.
Referenced by Delete().

| Resource::Clear | ( | $Field, | |
$ValueToClear = NULL |
|||
| ) |
Definition at line 1580 of file Resource.php.
References $DB, 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 1872 of file Resource.php.
References Clear().
Referenced by ClearByFieldId(), and Set().

| Resource::ClearByFieldId | ( | $FieldId, | |
$ValueToClear = NULL |
|||
| ) |
Definition at line 1573 of file Resource.php.
References ClearByField().
| Resource::Comments | ( | ) |
Definition at line 2042 of file Resource.php.
References Id().
|
static |
Create a new resource.
| int | $SchemaId | ID of metadata schema for new resource. |
| Exception | if resource creation failed. |
Definition at line 60 of file Resource.php.
References $DB, Id(), MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\SCHEMAID_DEFAULT, and MetadataField\UPDATEMETHOD_ONRECORDCREATE.
Referenced by CWUserFactory\CreateNewUser(), and ResourceFactory\DuplicateResource().

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

| Resource::Delete | ( | ) |
Remove resource (and accompanying associations) from database and delete any associated files.
Definition at line 154 of file Resource.php.
References $DB, 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 936 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 373 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, and Set().
Referenced by Clear(), FieldIsSet(), CWUser\Get(), GetAsArray(), GetByField(), GetByFieldId(), GetQualifierByField(), and Set().

| 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 712 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 677 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 694 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 758 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 774 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 802 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 788 of file Resource.php.
References GetQualifierByField().
| Resource::Id | ( | ) |
Retrieve numerical resource ID.
Definition at line 275 of file Resource.php.
Referenced by __construct(), Classifications(), Clear(), Comments(), Create(), Delete(), Get(), GetAsArray(), IsTempResource(), NumberOfComments(), NumberOfRatings(), Rating(), 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 295 of file Resource.php.
References $DB, Id(), and SchemaId().
Referenced by Clear(), and Set().

| Resource::NumberOfComments | ( | ) |
Definition at line 2062 of file Resource.php.
References Id().
| Resource::NumberOfRatings | ( | ) |
Definition at line 1930 of file Resource.php.
References CumulativeRating(), and Id().
| Resource::Rating | ( | $NewRating = NULL, |
|
$UserId = NULL |
|||
| ) |
Definition at line 1955 of file Resource.php.
| Resource::ScaledCumulativeRating | ( | ) |
Definition at line 1917 of file Resource.php.
References CumulativeRating().
| Resource::SchemaId | ( | ) |
Retrieve ID of schema for resource.
Definition at line 284 of file Resource.php.
Referenced by IsTempResource().

| Resource::Set | ( | $FieldNameOrObject, | |
| $NewValue, | |||
$Reset = FALSE |
|||
| ) |
Set value using field name or field object.
| mixed | $FieldNameOrObject | Field name or MetadataField object. |
| mixed | $NewValue | New value for field. |
| bool | $Reset | When TRUE Controlled Names, Classifications, and Options will be set to contain ONLY the contents of NewValue, rather than appending $NewValue to the current value. |
Definition at line 1008 of file Resource.php.
References $DB, 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, and MetadataSchema\MDFTYPE_USER.
Referenced by Get(), CWUser\Set(), SetByField(), and SetByFieldId().

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

| Resource::SetQualifierByFieldId | ( | $FieldId, | |
| $NewValue | |||
| ) |
Definition at line 1537 of file Resource.php.
References SetQualifierByField().
| Resource::Status | ( | ) |
Retrieve result of last operation if available.
Definition at line 266 of file Resource.php.
| Resource::UserCanAuthor | ( | $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 2114 of file Resource.php.
| Resource::UserCanAuthorField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to author specified metadata field.
Definition at line 2147 of file Resource.php.
| 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 2103 of file Resource.php.
| Resource::UserCanEditField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to edit specified metadata field.
Definition at line 2136 of file Resource.php.
| Resource::UserCanModifyField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to modify (Edit for perm resources, Author for temp) specified metadata field.
Definition at line 2159 of file Resource.php.
| Resource::UserCanView | ( | User | $User, |
$AllowHooksToModify = TRUE |
|||
| ) |
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 |
| bool | $AllowHooksToModify | TRUE if hook functions should be allowed to modify the return value (OPTIONAL default TRUE). |
Definition at line 2092 of file Resource.php.
| Resource::UserCanViewField | ( | $User, | |
| $FieldOrFieldName | |||
| ) |
Check whether user is allowed to view specified metadata field.
Definition at line 2125 of file Resource.php.
|
protected |
Definition at line 2168 of file Resource.php.
Referenced by Classifications(), Clear(), Create(), Delete(), IsTempResource(), Rating(), and Set().