We have moved to Github. Please open tickets there.

Opened 4 years ago

Last modified 15 months ago

#863 new Enhancement

Make the river site dependant

Reported by: fabcol Owned by:
Priority: normal Milestone: Long Term Future Release
Component: Core Version: 1.5
Severity: minor Keywords: multisite, federation
Cc: brettp Difficulty:

Description

I know that 1.5 wont support the full multisite feature (i hope that 2.0 will :) ) but just in case
These are my own hacks to make the river site dependant

1) add a site_guid field to the table system_log

2) modify in river.php, function get_river_from_log : inserting a site_guid field (see my code beyond)

3) modifiy in system_log.php, function system_log : inserting a site_guid field (see my code beyond)

My codes :

function get_river_from_log($by_user = "", $relationship = "", $limit = 10, $offset = 0)

{

global $CONFIG;


Get all potential river events from available view
$river_events = array();
$river_views = elgg_view_tree('river');
foreach ($river_views as $view)
{

$fragments = explode('/', $view);

if ((isset($fragments[svn:0])) && ($fragments[svn:0] == 'river'))
{

if (isset($fragments[svn:1]))
{

$f = array();
for ($n = 1; $n < count($fragments); $n++)
{

$val = sanitise_string($fragments[$n]);
switch($n)
{

case 1: $key = 'type'; break;
case 2: $key = 'subtype'; break;
case 3: $key = 'event'; break;

}
$f[$key] = $val;

}
$river_events[] = $f;


}

}

}
Construct query


Objects
$n = 0;
foreach ($river_events as $details)
{

Get what we're talking about


if ((isset($detailssubtype?)) && ($detailssubtype? == 'default')) $detailssubtype? = ;


if ((isset($detailstype?)) && (isset($detailsevent?))) {

if ($n>0) $obj_query .= " or ";


$access = "";
if ($detailstype?!='relationship')

$access = " and " . get_access_sql_suffix('sl');

Multisite : insert sl.site_guid field
$obj_query .= "( sl.site_guid = {$CONFIG->site_guid} and sl.object_type='{$detailstype?}' and sl.object_subtype='{$detailssubtype?}' and sl.event='{$detailsevent?}' $access )";


$n++;

}


}


User
$user = "sl.performed_by_guid in (".implode(',', $by_user).")";


Relationship
$relationship_query = "";
$relationship_join = "";
if ($relationship)
{

$relationship_join = " join {$CONFIG->dbprefix}entity_relationships r on sl.performed_by_guid=r.entity_guid ";
$relationship_query = "r.relationship = '$relationship'";

}


Multisite : add owner_guid = site_guid
$query = "SELECT sl.* from {$CONFIG->dbprefix}system_log sl $relationship_join where $user and $relationship_query ($obj_query) order by sl.time_created desc limit $offset, $limit";

fetch data from system log (needs optimisation)
return get_data($query);

}

function system_log($object, $event)

{

global $CONFIG;
static $logcache;

if ($object instanceof Loggable)
{


if (!is_array($logcache)) $logcache = array();


Has loggable interface, extract the necessary information and store
$object_id = (int)$object->getSystemLogID();
$object_class = $object->getClassName();
$object_type = $object->getType();
$object_subtype = $object->getSubtype();
$event = sanitise_string($event);
$time = time();
$performed_by = (int)$_SESSIONguid?;


if (isset($object->access_id))

$access_id = $object->access_id;

else

$access_id = ACCESS_PUBLIC;

if (isset($object->enabled))

$enabled = $object->enabled;

else

$enabled = 'yes';


if (isset($object->owner_guid))

$owner_guid = $object->owner_guid;

else

$owner_guid = 0;


Multisite : get the site information for multisite river

$site_guid = $CONFIG->site_guid;

end multisite


Create log if we haven't already created it
Multisite : insert site_guid field
if (!isset($logcache[$time][$object_id][$event])) {

insert_data("INSERT DELAYED into {$CONFIG->dbprefix}system_log (object_id, object_class, object_type, object_subtype, event, performed_by_guid, owner_guid, site_guid, access_id, enabled, time_created) VALUES ('$object_id','$object_class','$object_type', '$object_subtype', '$event',$performed_by, $owner_guid, $site_guid, $access_id, '$enabled', '$time')");


$logcache[$time][$object_id][$event] = true;

}


return true;


}

}

Change History (6)

comment:1 Changed 4 years ago by marcus

  • Keywords multisite added

comment:2 Changed 4 years ago by fabcol

Things have changed since that trac. Prb is still the same in 1.5 but the river feature has been changed from 1.2.

See the way to handle this in 1.5 there https://trac.elgg.org/elgg/ticket/1063

comment:3 Changed 3 years ago by brettp

  • Priority changed from major to minor

comment:4 Changed 3 years ago by brettp

  • Milestone changed from Elgg 1.5 to Elgg 2.0

comment:5 Changed 2 years ago by cash

  • Milestone changed from Elgg 2.0 to Future Release

comment:6 Changed 15 months ago by ewinslow

  • Keywords multisite, federation added; multisite removed

This could be helpful for implementing federation.

Note: See TracTickets for help on using tickets.