CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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 1788 of file Resource.php.

References Id().

Referenced by Delete().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

Resource::ClearByField | ( |  | $Field,
|  |  | $ValueToClear = `NULL`
| ) |  |

Definition at line 1780 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 1487 of file Resource.php.

References ClearByField().

Resource::Comments | ( |  | ) |

Definition at line 1945 of file Resource.php.

References Id().

static Resource::Create | ( |  | $SchemaId | ) |
| static

Create a new resource.

Parameters

  int | $SchemaId | ID 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 1817 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 139 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 | $FieldNameOrObject | Full name of field or a Field object.
  bool | $IgnorePadding | Optional 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 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.

Parameters

  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.

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 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().

Here is the caller graph for this function:

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

Retrieve all resource values as an array.

Parameters

  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)

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 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().

See Also
  Get

Definition at line 640 of file Resource.php.

References Get().

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

Retrieve value using field ID.

Parameters

  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.

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 657 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 | $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.

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 721 of file Resource.php.

References GetByFieldId().

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

Retrieve qualifier by field name.

Parameters

  string | $FieldName | Full name of field.
  bool | $ReturnObject | If 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 737 of file Resource.php.

References GetQualifierByField().

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

Retrieve qualifier by Field object.

Parameters

  MetadataField | $Field | Field object.
  bool | $ReturnObject | If 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 765 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 | $FieldId | ID of field.
  int | $ReturnObject | If 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 751 of file Resource.php.

References GetQualifierByField().

Resource::Id | ( |  | ) |

Retrieve numerical resource ID.

Returns
  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().

Here is the caller graph for this function:

Resource::IsTempResource | ( |  | $NewSetting = `NULL` | ) |

Get/set whether resource is a temporary record.

Parameters

  bool | $NewSetting | TRUE/FALSE setting for whether resource is temporary. (OPTIONAL)

Returns
  TRUE if resource is temporary record, or FALSE otherwise.

Definition at line 266 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 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().)

Parameters

  int | $ResourceId | ID 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 1820 of file Resource.php.

References CumulativeRating().

Resource::SchemaId | ( |  | ) |

Retrieve ID of schema for resource.

Returns
  int Schema ID.

Definition at line 258 of file Resource.php.

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

Here is the caller graph for this function:

Resource::Set | ( |  | $FieldNameOrObject,
|  |  | $NewValue
| ) |  |

Set value using field name or field object.

Parameters

  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().

Here is the caller graph for this function:

Resource::SetByField | ( |  | $Field,
|  |  | $NewValue
| ) |  |

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

See Also
  Resource::Set()

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().

Here is the caller graph for this function:

Resource::SetQualifierByFieldId | ( |  | $FieldId,
|  |  | $NewValue
| ) |  |

Definition at line 1451 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 246 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 | $User | User to check.
  mixed | $FieldOrFieldName | Field name or object.

Returns
  TRUE if user can author field, otherwise FALSE.

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.

Parameters

  User | $User | user

Returns
  bool TRUE if the user can edit the resource and FALSE otherwise

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.

Parameters

  User | $User | User to check.
  mixed | $FieldOrFieldName | Field name or object.

Returns
  TRUE if user can edit field, otherwise FALSE.

Definition at line 2165 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 | $User | user

Returns
  bool TRUE if the user can view the resource and FALSE otherwise

Definition at line 1993 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 | $User | User to check.
  mixed | $FieldOrFieldName | Field name or object.

Returns
  TRUE if user can view field, otherwise FALSE.

Definition at line 2056 of file Resource.php.

References UserCanEditField().

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

- objects/Resource.php