Elgg  Version 1.9
ElggRiverItem.php
Go to the documentation of this file.
1 <?php
22  public $id;
23  public $subject_guid;
24  public $object_guid;
25  public $target_guid;
27  public $type;
28  public $subtype;
29  public $action_type;
30  public $access_id;
31  public $view;
32  public $posted;
33  public $enabled;
34 
40  public function __construct($object) {
41  if (!($object instanceof stdClass)) {
42  throw new InvalidParameterException("Invalid input to ElggRiverItem constructor");
43  }
44 
45  // the casting is to support typed serialization like json
46  $int_types = array('id', 'subject_guid', 'object_guid', 'target_guid', 'annotation_id', 'access_id', 'posted');
47  foreach ($object as $key => $value) {
48  if (in_array($key, $int_types)) {
49  $this->$key = (int)$value;
50  } else {
51  $this->$key = $value;
52  }
53  }
54  }
55 
61  public function getSubjectEntity() {
62  return get_entity($this->subject_guid);
63  }
64 
70  public function getObjectEntity() {
71  return get_entity($this->object_guid);
72  }
73 
79  public function getTargetEntity() {
80  return get_entity($this->target_guid);
81  }
82 
88  public function getAnnotation() {
89  return elgg_get_annotation_from_id($this->annotation_id);
90  }
91 
97  public function getView() {
98  return $this->view;
99  }
100 
107  public function getPostedTime() {
108  elgg_deprecated_notice("ElggRiverItem::getPostedTime() deprecated in favor of getTimePosted()", 1.9);
109  return (int)$this->posted;
110  }
111 
117  public function getTimePosted() {
118  return (int)$this->posted;
119  }
120 
129  public function getType() {
130  return 'river';
131  }
132 
140  public function getSubtype() {
141  return 'item';
142  }
143 
149  public function toObject() {
150  $object = new stdClass();
151  $object->id = $this->id;
152  $object->subject_guid = $this->subject_guid;
153  $object->object_guid = $this->object_guid;
154  $object->annotation_id = $this->annotation_id;
155  $object->read_access = $this->access_id;
156  $object->action = $this->action_type;
157  $object->time_posted = date('c', $this->getTimePosted());
158  $object->enabled = $this->enabled;
159  $params = array('item' => $this);
160  return elgg_trigger_plugin_hook('to:object', 'river_item', $params, $object);
161  }
162 
163 }
getType()
Get the type of the object.
__construct($object)
Construct a river item object given a database row.
toObject()
Get a plain old object copy for public consumption.
$object
Definition: upgrade.php:12
getSubjectEntity()
Get the subject of this river item.
$value
Definition: longtext.php:29
getTimePosted()
Get the time this activity was posted.
getSubtype()
Get the subtype of the object.
$params
Definition: login.php:72
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
$key
Definition: summary.php:34
getAnnotation()
Get the Annotation for this river item.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
Definition: elgglib.php:925
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1171
getView()
Get the view used to display this river item.
getTargetEntity()
Get the target of this river item.
getPostedTime()
Get the time this activity was posted.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:604
getObjectEntity()
Get the object of this river item.