$this->attributes['access_id'] = ACCESS_PRIVATE;
$this->attributes['time_created'] = "";
$this->attributes['time_updated'] = "";
+ $this->attributes['last_action'] = '';
$this->attributes['enabled'] = "yes";
// There now follows a bit of a hack
* method copies metadata but does not copy over annotations, or private settings.
*
* Note: metadata will have its owner and access id set when the entity is saved
- * and it will be the same as that off the entity.
+ * and it will be the same as that of the entity.
*/
public function __clone() {
if ((int) $this->guid > 0) {
return create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID(), $multiple);
} else {
- //$this->temp_metadata[$name] = $value;
-
if (($multiple) && (isset($this->temp_metadata[$name]))) {
if (!is_array($this->temp_metadata[$name])) {
$tmp = $this->temp_metadata[$name];
}
return insert_data("INSERT into {$CONFIG->dbprefix}entities
- (type, subtype, owner_guid, site_guid, container_guid, access_id, time_created, time_updated) values
- ('$type',$subtype, $owner_guid, $site_guid, $container_guid, $access_id, $time, $time)");
+ (type, subtype, owner_guid, site_guid, container_guid, access_id, time_created, time_updated, last_action) values
+ ('$type',$subtype, $owner_guid, $site_guid, $container_guid, $access_id, $time, $time, $time)");
}
/**
return $return;
}
+
+/**
+ * Update last_action on the given entity.
+ *
+ * @param int $guid Entity annotation|relationship action carried out on
+ * @param int $posted Timestamp of last action
+ **/
+function update_entity_last_action($guid, $posted = NULL){
+ global $CONFIG;
+ $guid = (int)$guid;
+
+ if (!$posted) {
+ $posted = time();
+ }
+
+ if ($guid){
+ //now add to the river updated table
+ $query = update_data("UPDATE {$CONFIG->dbprefix}entities SET last_action = {$posted} WHERE guid = {$guid}");
+ if ($query) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+}
+
/**
* Garbage collect stub and fragments from any broken delete/create calls
*
" object_guid = {$object_guid}, " .
" annotation_id = {$annotation_id}, " .
" posted = {$posted} ");
-
+
//update the entities which had the action carried out on it
if($insert_data){
update_entity_last_action($object_guid, $posted);
*
* @param int|array $subject_guid Acting entity to restrict to. Default: all
* @param int|array $object_guid Entity being acted on to restrict to. Default: all
- * @param string $subject_relationship If set to a relationship type, this will use
- * $subject_guid as the starting point and set the subjects to be all users this
+ * @param string $subject_relationship If set to a relationship type, this will use
+ * $subject_guid as the starting point and set the subjects to be all users this
* entity has this relationship with (eg 'friend'). Default: blank
* @param string $type The type of entity to restrict to. Default: all
* @param string $subtype The subtype of entity to restrict to. Default: all
} else {
if (!is_array($subject_guid)) {
if ($entities = elgg_get_entities_from_relationship(array(
- 'relationship' => $subject_relationship,
- 'relationship_guid' => $subject_guid,
+ 'relationship' => $subject_relationship,
+ 'relationship_guid' => $subject_guid,
'limit' => 9999))
) {
$guids = array();
// Construct main SQL
$sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,annotation_id,posted" .
- " from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";
+ " from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";
// Get data
return get_data($sql);
*
* @param int|array $subject_guid Acting entity to restrict to. Default: all
* @param int|array $object_guid Entity being acted on to restrict to. Default: all
- * @param string $subject_relationship If set to a relationship type, this will use
- * $subject_guid as the starting point and set the subjects to be all users this
+ * @param string $subject_relationship If set to a relationship type, this will use
+ * $subject_guid as the starting point and set the subjects to be all users this
* entity has this relationship with (eg 'friend'). Default: blank
* @param string $type The type of entity to restrict to. Default: all
* @param string $subtype The subtype of entity to restrict to. Default: all
// Construct main SQL
$sql = "select er.*" .
- " from {$CONFIG->dbprefix}river er, {$CONFIG->dbprefix}entities e " .
- " where {$whereclause} AND er.object_guid = e.guid GROUP BY object_guid " .
- " ORDER BY e.last_action desc LIMIT {$offset},{$limit}";
+ " from {$CONFIG->dbprefix}river er, {$CONFIG->dbprefix}entities e " .
+ " where {$whereclause} AND er.object_guid = e.guid GROUP BY object_guid " .
+ " ORDER BY e.last_action desc LIMIT {$offset},{$limit}";
// Get data
return get_data($sql);
*
* @param int|array $subject_guid Acting entity to restrict to. Default: all
* @param int|array $object_guid Entity being acted on to restrict to. Default: all
- * @param string $subject_relationship If set to a relationship type, this will use
- * $subject_guid as the starting point and set the subjects to be all users this
+ * @param string $subject_relationship If set to a relationship type, this will use
+ * $subject_guid as the starting point and set the subjects to be all users this
* entity has this relationship with (eg 'friend'). Default: blank
* @param string $type The type of entity to restrict to. Default: all
* @param string $subtype The subtype of entity to restrict to. Default: all
}else{
$riveritems = elgg_get_river_items($subject_guid,$object_guid,$subject_relationship,$type,$subtype,$action_type,($limit + 1),$offset,$posted_min,$posted_max);
}
-
+
// Get river items, if they exist
if ($riveritems) {
return '';
}
-/**
- * Update last_action on the given entity.
- *
- * @param int $guid Entity annotation|relationship action carried out on
- * @param int $posted Timestamp of last action
- **/
-function update_entity_last_action($guid, $posted){
- global $CONFIG;
- if(!$posted)
- $posted = time();
- $guid = (int)$guid;
- if($guid){
- //now add to the river updated table
- $query = update_data("UPDATE {$CONFIG->dbprefix}entities SET last_action = {$posted} WHERE guid = {$guid}");
- if($query)
- return true;
- else
- return false;
- }else{
- return false;
- }
-}
/**
* This function has been added here until we decide if it is going to roll into core or not
* Add access restriction sql code to a given query.