CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

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

Public Member Functions | List of all members
Resource Class Reference

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

## Public Member Functions
| Resource ($ResourceId=NULL)
| Object constructor.
| Delete ()
| Remove resource (and accompanying associations) from database and delete any associated files.
| Status ()
| Retrieve result of last operation if available.
| Id ()
| Retrieve numerical resource ID.
| IsTempResource ($NewSetting=NULL)
| Get/set whether resource is a temporary record.
| Get ($FieldNameOrObject, $ReturnObject=FALSE, $IncludeVariants=FALSE)
| Retrieve value using field name or field object.
| GetByField ($FieldNameOrObject, $ReturnObject=FALSE, $IncludeVariants=FALSE)
| Old method for retrieving values, deprecated in favor of Get().
| GetByFieldId ($FieldId, $ReturnObject=FALSE, $IncludeVariants=FALSE)
| Retrieve value using field ID.
| GetAsArray ($IncludeDisabledFields=FALSE, $ReturnObjects=TRUE)
| Retrieve all resource values as an array.
| GetMapped ($MappedName, $ReturnObject=FALSE, $IncludeVariants=FALSE)
| Retrieve value using standard (mapped) field name.
| GetQualifier ($FieldName, $ReturnObject=TRUE)
| Retrieve qualifier by field name.
| GetQualifierByFieldId ($FieldId, $ReturnObject=TRUE)
| Retrieve qualifier by field ID.
| GetQualifierByField ($Field, $ReturnObject=TRUE)
| Retrieve qualifier by Field object.
| Set ($FieldNameOrObject, $NewValue)
| SetByField ($Field, $NewValue)
| SetByFieldId ($FieldId, $NewValue)
| SetQualifier ($FieldName, $NewValue)
| SetQualifierByFieldId ($FieldId, $NewValue)
| SetQualifierByField ($Field, $NewValue)
| Clear ($FieldName, $ValueToClear=NULL)
| ClearByFieldId ($FieldId, $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.
| UserCanEdit ($User)
| UserCanViewField ($User, $FieldOrFieldName)
| Check whether user is allowed to view specified metadata field.
| UserCanAuthorField ($User, $FieldOrFieldName)
| Check whether user is allowed to author specified metadata field.
| UserCanEditField ($User, $FieldOrFieldName)
| Check whether user is allowed to edit specified metadata field.

## Detailed Description

Represents a "resource" in CWIS.

Definition at line 13 of file Resource.php.

## Member Function Documentation

Resource::Classifications | ( |  | ) |

Definition at line 1538 of file Resource.php.

References Id().

Referenced by Delete().

Here is the caller graph for this function:

Resource::Clear | ( |  | $FieldName,
|  |  | $ValueToClear = `NULL`
| ) |  |

Definition at line 1269 of file Resource.php.

References ClearByField().

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

Definition at line 1283 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_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

Referenced by Clear(), and ClearByFieldId().

Here is the caller graph for this function:

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

Definition at line 1276 of file Resource.php.

References ClearByField().

Resource::Comments | ( |  | ) |

Definition at line 1695 of file Resource.php.

References Id().

Resource::CumulativeRating | ( |  | ) |

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

References Classifications(), Id(), and MetadataSchema\MDFTYPE_IMAGE.

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

Retrieve value using field name or field object.

Parameters

  FieldNameOrObject | Full name of field or a Field object.
  ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE.
  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
  GetByFieldId

Definition at line 325 of file Resource.php.

References FileFactory\GetFilesForResource(), Id(), MetadataSchema\MDFSTAT_OK, 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_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

Referenced by ClearByField(), GetAsArray(), GetByField(), GetByFieldId(), GetQualifierByField(), Set(), UserCanAuthorField(), UserCanEditField(), UserCanView(), and UserCanViewField().

Here is the caller graph for this function:

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

Retrieve all resource values as an array.

Parameters

  IncludeDisabledFields | Include values for disabled fields. (OPTIONAL, defaults to FALSE)
  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
  Get

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

References Get().

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

Retrieve value using field ID.

Parameters

  FieldId | ID of field.
  ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE.
  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
  Get

Definition at line 562 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

  MappedName | Standard field name.
  ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE.
  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
  Get

Definition at line 626 of file Resource.php.

References GetByFieldId().

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

Retrieve qualifier by field name.

Parameters

  FieldName | Full name of field.
  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 642 of file Resource.php.

References GetQualifierByField().

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

Retrieve qualifier by Field object.

Parameters

  Field | Field object.
  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 670 of file Resource.php.

References $Items, Get(), MetadataSchema\MDFSTAT_OK, 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

  FieldId | ID of field.
  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 656 of file Resource.php.

References GetQualifierByField().

Resource::Id | ( |  | ) |

Retrieve numerical resource ID.

Returns
  Resource ID.

Definition at line 244 of file Resource.php.

Referenced by Classifications(), ClearByField(), Comments(), Delete(), Get(), GetAsArray(), IsTempResource(), NumberOfComments(), NumberOfRatings(), Rating(), Resource(), and Set().

Here is the caller graph for this function:

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

Get/set whether resource is a temporary record.

Parameters

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

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

Definition at line 251 of file Resource.php.

References Id().

Referenced by ClearByField(), and Set().

Here is the caller graph for this function:

Resource::NumberOfComments | ( |  | ) |

Definition at line 1715 of file Resource.php.

References Id().

Resource::NumberOfRatings | ( |  | ) |

Definition at line 1583 of file Resource.php.

References CumulativeRating(), and Id().

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

Definition at line 1608 of file Resource.php.

References Id().

Resource::Resource | ( |  | $ResourceId = `NULL` | ) |

Object constructor.

Parameters

  ResourceId | ID of resource to load. New resource is created if no ID is supplied.

Definition at line 22 of file Resource.php.

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

Resource::ScaledCumulativeRating | ( |  | ) |

Definition at line 1570 of file Resource.php.

References CumulativeRating().

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

Definition at line 800 of file Resource.php.

References Classification\CLASSSTAT_OK, 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_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, and MetadataSchema\MDFTYPE_USER.

Referenced by SetByField(), and SetByFieldId().

Here is the caller graph for this function:

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

Definition at line 1216 of file Resource.php.

References Set().

Referenced by Resource().

Here is the caller graph for this function:

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

Definition at line 1219 of file Resource.php.

References Set().

Resource::SetQualifier | ( |  | $FieldName,
|  |  | $NewValue
| ) |  |

Definition at line 1226 of file Resource.php.

References SetQualifierByField().

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

Definition at line 1240 of file Resource.php.

Referenced by SetQualifier(), and SetQualifierByFieldId().

Here is the caller graph for this function:

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

Definition at line 1233 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 238 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 to check.
  FieldOrFieldName | Field name or object.

Returns
  TRUE if user can author field, otherwise FALSE.

Definition at line 1909 of file Resource.php.

References Get(), MetadataField\USERISVALUE_AND, MetadataField\USERISVALUE_OR, and MetadataField\USERISVALUE_UNSET.

Referenced by UserCanEditField().

Here is the caller graph for this function:

Resource::UserCanEdit | ( |  | $User | ) |

Definition at line 1780 of file Resource.php.

References UserCanEditField().

Resource::UserCanEditField | ( |  | $User,
|  |  | $FieldOrFieldName
| ) |  |

Check whether user is allowed to edit specified metadata field.

Parameters

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

Returns
  TRUE if user can edit field, otherwise FALSE.

Definition at line 2001 of file Resource.php.

References Get(), UserCanAuthorField(), MetadataField\USERISVALUE_AND, MetadataField\USERISVALUE_OR, and MetadataField\USERISVALUE_UNSET.

Referenced by UserCanEdit(), and 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 1743 of file Resource.php.

References Get(), User\HasPriv(), User\Name(), and Status().

Resource::UserCanViewField | ( |  | $User,
|  |  | $FieldOrFieldName
| ) |  |

Check whether user is allowed to view specified metadata field.

Parameters

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

Returns
  TRUE if user can view field, otherwise FALSE.

Definition at line 1820 of file Resource.php.

References Get(), UserCanEditField(), MetadataField\USERISVALUE_AND, MetadataField\USERISVALUE_OR, and MetadataField\USERISVALUE_UNSET.

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

- objects/Resource.php