CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

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

Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
Resource Class Reference

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

Inheritance diagram for Resource:
[legend]
Collaboration diagram for Resource:
[legend]

## 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...
| UpdateAutoupdateFields ($UpdateType, $User=NULL)
| Update the auto-updated fields as necessary. More...
| Id ()
| Retrieve numerical resource ID. More...
| SchemaId ()
| Retrieve ID of schema for resource. More...
| Schema ()
| Get MetadataSchema for resource. More...
| IsTempResource ($NewSetting=NULL)
| Get/set whether resource is a temporary record. More...
| GetViewPageUrl ()
| Retrieve view page URL for this resource. More...
| Get ($Field, $ReturnObject=FALSE, $IncludeVariants=FALSE)
| Retrieve value using field name or field object. More...
| GetForDisplay ($FieldNameOrObject, $ReturnObject=TRUE, $IncludeVariants=FALSE)
| Retrieve value using field name or field object, signaling EVENT_FIELD_DISPLAY_FILTER to allow other code to possibly modify the value before it's returned. 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...
| GetImageUrls ($FieldNameOrObject, $ImageSize=SPTImage::SIZE_FULL)
| Get URLs for images, returning CleanURLs when possible and direct paths to image files otherwise. More...
| Set ($Field, $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)
| Set field value using field ID. More...
| SetQualifier ($FieldName, $NewValue)
| Set qualifier using field name. More...
| SetQualifierByFieldId ($FieldId, $NewValue)
| Set qualifier using field ID. More...
| SetQualifierByField ($Field, $NewValue)
| Set qualifier using field object. More...
| ClearByFieldId ($FieldId, $ValueToClear=NULL)
| Clear field value specified by field ID. More...
| Clear ($Field, $ValueToClear=NULL)
| Clear field value. More...
| ClearByField ($Field, $ValueToClear=NULL)
| Clear field value. More...
| Classifications ()
| Get 2D array of classifications associated with resource. More...
| CumulativeRating ()
| Get cumulative rating (range is usually 0-100) More...
| ScaledCumulativeRating ()
| Return cumulative rating scaled to 1/10th. More...
| NumberOfRatings ()
| Get current number of ratings for resource. More...
| Rating ($NewRating=NULL, $UserId=NULL)
| Get/set rating by a specific user for resource. More...
| Comments ()
| Get comments for resource. More...
| NumberOfComments ()
| Get current number of comments for resource. More...
| 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...
| UserCanModify ($User)
| Check if the user is allowed to modify (Edit for perm resources, Author for temp) a specified resources. More...
| UserCanViewField ($User, $FieldOrFieldName)
| Check whether user is allowed to view specified metadata field. More...
| UserCanViewMappedField ($User, $MappedName)
| Check whether user can view specified standard (mapped) 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...
| QueueSearchAndRecommenderUpdate ()
| Update search and recommender system DBs. More...
Public Member Functions inherited from Item
| __construct ($Id)
| Constructor, used to load existing items. More...
| Destroy ()
| Destroy item. More...
| Delete ()
| Destroy item. More...
| Id ()
| Get item ID. More...
| Name ($NewValue=DB_NOVALUE)
| Get/set name of item. More...
| DateCreated ($NewValue=DB_NOVALUE)
| Get/set when item was created. More...
| CreatedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who created the item. More...
| DateLastModified ($NewValue=DB_NOVALUE)
| Get/set when item was last modified. More...
| LastModifiedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who last modified the item. More...

## Static Public Member Functions
static | Create ($SchemaId)
| Create a new resource. More...
static | GetSchemaForResource ($ResourceId)
| Get schema ID for specified resource(s). More...
Static Public Member Functions inherited from Item
static | GetCanonicalId ($Id)
| Normalize item ID to canonical form. More...
static | ItemExists ($Id)
| Check whether an item exists with the specified ID. More...

## Static Protected Member Functions
static | SetDatabaseAccessValues ($ClassName)
| Set the database access values (table name, ID column name, name column name) for specified class. More...
Static Protected Member Functions inherited from Item
static | CreateWithValues ($Values)
| Create a new item, using specified initial database values. More...
static | SetDatabaseAccessValues ($ClassName)
| Set the database access values (table name, ID column name, name column name) for specified class. More...

## Additional Inherited Members
Public Attributes inherited from Item
const | NO_ITEM = -2123456789
| ID value used to indicate no item. More...
Protected Member Functions inherited from Item
| UpdateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(). More...
| UpdateDateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(), with preprocessing of new values to convert them into an SQL-compatible date format. More...
Protected Attributes inherited from Item
| $DB
| $Id
| $ItemIdColumnName
| $ItemNameColumnName
| $ItemTableName
| $ValueCache = array()
Static Protected Attributes inherited from Item
static | $ItemIdColumnNames
static | $ItemNameColumnNames
static | $ItemTableNames

## Detailed Description

Represents a "resource" in CWIS.

Definition at line 13 of file Resource.php.

## Constructor & Destructor Documentation

Resource::__construct | ( |  | $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()

Exceptions

  InvalidArgumentException | If ID is invalid.

Definition at line 25 of file Resource.php.

References CumulativeRating(), and SchemaId().

## Member Function Documentation

Resource::Classifications | ( |  | ) |

Get 2D array of classifications associated with resource.

Returns
  array Array where first index is classification (field) name, second index is classification ID.

Definition at line 2149 of file Resource.php.

References Item\$DB, and Id().

Referenced by Delete().

Here is the caller graph for this function:

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

Clear field value.

Parameters

  object | $Field | Metadata field.
  mixed | $ValueToClear | Specific value to clear (for fields that support multiple values). (OPTIONAL)

Definition at line 1785 of file Resource.php.

References Item\$DB, Item\$Id, SPTImage\ClearImageSymlinksForResource(), 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 Schema().

Referenced by ClearByField(), and ClearByFieldId().

Here is the caller graph for this function:

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

Clear field value.

DEPRECATED in favor of Clear().

Parameters

  object | $Field | Metadata field.
  mixed | $ValueToClear | Specific value to clear (for fields that support multiple values). (OPTIONAL)

See also
  Resource::Clear()

Deprecated:

Definition at line 2137 of file Resource.php.

References Clear().

Referenced by Set().

Here is the caller graph for this function:

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

Clear field value specified by field ID.

Parameters

  int | $FieldId | Metadata field ID.
  mixed | $ValueToClear | Specific value to clear (for fields that support multiple values). (OPTIONAL)

Definition at line 1773 of file Resource.php.

References Clear(), and Schema().

Resource::Comments | ( |  | ) |

Get comments for resource.

Returns
  array Comments as Message objects.

Definition at line 2328 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.

Exceptions

  Exception | If resource creation failed.

Definition at line 48 of file Resource.php.

References Item\$DB, Item\$Id, Id(), MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\SCHEMAID_DEFAULT, and MetadataField\UPDATEMETHOD_ONRECORDCREATE.

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

Here is the caller graph for this function:

Resource::CumulativeRating | ( |  | ) |

Get cumulative rating (range is usually 0-100)

Returns
  int Rating value.

Definition at line 2182 of file Resource.php.

Referenced by __construct(), GetAsArray(), GetSchemaForResource(), NumberOfRatings(), 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 Item\$DB, 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 1038 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, MetadataSchema\MDFTYPE_USER, and Schema().

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

Retrieve value using field name or field object.

Parameters

  mixed | $Field | Field ID or 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.

Definition at line 415 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, Schema(), and SchemaId().

Referenced by Clear(), FieldIsSet(), CWUser\Get(), GetAsArray(), GetByField(), GetByFieldId(), GetForDisplay(), GetImageUrls(), GetMapped(), GetQualifierByField(), GetSchemaForResource(), and Set().

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

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

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

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

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::Get()

Deprecated:

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

Deprecated:

Definition at line 795 of file Resource.php.

References Get().

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

Retrieve value using field name or field object, signaling EVENT_FIELD_DISPLAY_FILTER to allow other code to possibly modify the value before it's returned.

Note that the default for the $ReturnObject parameter is TRUE, which is the opposite of the default for the same parameter to all other Resource::Get*() methods.

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. (OPTIONAL, defaults to TRUE)
  bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. (OPTIONAL, defaults to FALSE)

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::Get()

Definition at line 739 of file Resource.php.

References Get(), and Schema().

Resource::GetImageUrls | ( |  | $FieldNameOrObject,
|  |  | $ImageSize = `SPTImage::SIZE_FULL`
| ) |  |

Get URLs for images, returning CleanURLs when possible and direct paths to image files otherwise.

Parameters

  mixed | $FieldNameOrObject | Full field name, FieldId, or a MetadataField object.
  mixed | $ImageSize | Desired size as an SPTImage::SIZE_ constant.

Returns
  array of image URLs, keyed by ImageId

Definition at line 1108 of file Resource.php.

References Get(), Id(), and Schema().

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

References Get(), and Schema().

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

References GetQualifierByField(), and Schema().

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

References GetQualifierByField(), and Schema().

static Resource::GetSchemaForResource | ( |  | $ResourceId | ) |
| static

Get schema ID for specified resource(s).

Parameters

  int | $ResourceId | ID of resource or array of IDs of resources.

Returns
  int Schema ID or array of schema IDs indexed by resource ID.

Definition at line 2502 of file Resource.php.

References Item\$DB, CumulativeRating(), Get(), Id(), and Schema().

Resource::GetViewPageUrl | ( |  | ) |

Retrieve view page URL for this resource.

Returns
  string view page url

Definition at line 391 of file Resource.php.

References Id(), and Schema().

Resource::Id | ( |  | ) |

Retrieve numerical resource ID.

Returns
  Resource ID.

Definition at line 291 of file Resource.php.

References Item\$Id.

Referenced by Classifications(), Clear(), Comments(), Create(), Delete(), Get(), GetAsArray(), GetImageUrls(), GetSchemaForResource(), GetViewPageUrl(), IsTempResource(), NumberOfComments(), NumberOfRatings(), Rating(), 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 320 of file Resource.php.

References Item\$DB, Item\$Id, Id(), and SchemaId().

Referenced by Clear(), QueueSearchAndRecommenderUpdate(), and Set().

Here is the caller graph for this function:

Resource::NumberOfComments | ( |  | ) |

Get current number of comments for resource.

Returns
  int Number of comments.

Definition at line 2351 of file Resource.php.

References Id().

Resource::NumberOfRatings | ( |  | ) |

Get current number of ratings for resource.

Returns
  int Ratings count.

Definition at line 2207 of file Resource.php.

References CumulativeRating(), and Id().

Resource::QueueSearchAndRecommenderUpdate | ( |  | ) |

Update search and recommender system DBs.

Definition at line 2485 of file Resource.php.

References IsTempResource().

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

Get/set rating by a specific user for resource.

Parameters

  int | $NewRating | New rating value.
  int | $UserId | ID of user rating resource.

Returns
  int Current rating value of resource by user or NULL if user has not rated resource..

Definition at line 2238 of file Resource.php.

References Item\$DB, and Id().

Resource::ScaledCumulativeRating | ( |  | ) |

Return cumulative rating scaled to 1/10th.

(Range is usually 0-10.)

Returns
  int Scaled rating value or NULL if no cumulative rating available.

Definition at line 2191 of file Resource.php.

References CumulativeRating().

Resource::Schema | ( |  | ) |

Get MetadataSchema for resource.

Returns
  object Our schema.

Definition at line 309 of file Resource.php.

Referenced by Clear(), ClearByFieldId(), FieldIsSet(), Get(), GetAsArray(), GetForDisplay(), GetImageUrls(), GetMapped(), GetQualifier(), GetQualifierByFieldId(), GetSchemaForResource(), GetViewPageUrl(), Set(), SetQualifier(), SetQualifierByFieldId(), UpdateAutoupdateFields(), and UserCanViewMappedField().

Here is the caller graph for this function:

Resource::SchemaId | ( |  | ) |

Retrieve ID of schema for resource.

Returns
  int Schema ID.

Definition at line 300 of file Resource.php.

Referenced by __construct(), Get(), IsTempResource(), and Set().

Here is the caller graph for this function:

Resource::Set | ( |  | $Field,
|  |  | $NewValue,
|  |  | $Reset = `FALSE`
| ) |  |

Set value using field name or field object.

Parameters

  mixed | $Field | Field ID or full name of field or a Field 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.

Exceptions

  Exception | When attempting to set a value for a field that is part of a different schema than the resource.
  InvalidArgumentException | When attempting to set a controlled name with an invalid ID.

Definition at line 1143 of file Resource.php.

References Item\$DB, Item\$Id, ClearByField(), SPTImage\ClearImageSymlinksForResource(), 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, Schema(), SchemaId(), and ControlledName\STATUS_OK.

Referenced by CWUser\Set(), SetByField(), SetByFieldId(), and UpdateAutoupdateFields().

Here is the caller graph for this function:

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

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

Parameters

  object | $Field | MetadataField object.
  mixed | $NewValue | New value for field.

See also
  Resource::Set()

Deprecated:

Definition at line 1695 of file Resource.php.

References Set().

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

Set field value using field ID.

Parameters

  int | $FieldId | Metadata field ID.
  mixed | $NewValue | Value to set.

See also
  Resource::Set()

Deprecated:

Definition at line 1707 of file Resource.php.

References Set().

static Resource::SetDatabaseAccessValues | ( |  | $ClassName | ) |
| static protected

Set the database access values (table name, ID column name, name column name) for specified class.

This may be overridden in a child class, if different values are needed.

Parameters

  string | $ClassName | Class to set values for.

Definition at line 2816 of file Resource.php.

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

Set qualifier using field name.

Parameters

  string | $FieldName | Metadata field name.
  mixed | $NewValue | Qualifier object or ID.

Definition at line 1717 of file Resource.php.

References Schema(), and SetQualifierByField().

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

Set qualifier using field object.

Parameters

  object | $Field | Metadata field.
  mixed | $NewValue | Qualifier object or ID.

Definition at line 1739 of file Resource.php.

Referenced by SetQualifier(), and SetQualifierByFieldId().

Here is the caller graph for this function:

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

Set qualifier using field ID.

Parameters

  int | $FieldId | Metadata field ID.
  mixed | $NewValue | Qualifier object or ID.

Definition at line 1728 of file Resource.php.

References Schema(), and SetQualifierByField().

Resource::UpdateAutoupdateFields | ( |  | $UpdateType,
|  |  | $User = `NULL`
| ) |  |

Update the auto-updated fields as necessary.

Parameters

  int | $UpdateType | Type of update being performed, one of the MetadataField::UPDATEMETHOD_ constants.
  CWUser | $User | User responsible for the update (OPTIONAL).

Definition at line 259 of file Resource.php.

References MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_USER, Schema(), and Set().

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.

Parameters

  User | $User | User to check against.

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

Definition at line 2403 of file Resource.php.

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 2461 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.

Parameters

  User | $User | User to check against.

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

Definition at line 2392 of file Resource.php.

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

Resource::UserCanModify | ( |  | $User | ) |

Check if the user is allowed to modify (Edit for perm resources, Author for temp) a specified resources.

Parameters

  User | $User | User to check.

Returns
  bool TRUE if the user can modify the resource, FALSE otherwise

Definition at line 2414 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.

Parameters

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

Returns
  TRUE if user can modify field, otherwise FALSE.

Definition at line 2473 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.

Parameters

  User | $User | User to check against.
  bool | $AllowHooksToModify | TRUE if hook functions should be allowed to modify the return value (OPTIONAL default TRUE).

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

Definition at line 2381 of file Resource.php.

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

Resource::UserCanViewMappedField | ( |  | $User,
|  |  | $MappedName
| ) |  |

Check whether user can view specified standard (mapped) metadata field.

Parameters

  User | $User | User to check.
  string | $MappedName | Name of standard (mapped) field.

Returns
  TRUE if user can view field, otherwise FALSE.

Definition at line 2437 of file Resource.php.

References Schema().

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

- objects/Resource.php