aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README12
-rw-r--r--boot.php13
-rw-r--r--include/event.php2
-rwxr-xr-xinclude/items.php10
-rw-r--r--include/security.php40
-rw-r--r--include/text.php6
-rw-r--r--mod/dfrn_confirm.php4
-rw-r--r--mod/item.php116
-rwxr-xr-xmod/like.php2
-rw-r--r--mod/manage.php4
-rwxr-xr-xmod/mood.php2
-rw-r--r--mod/photos.php6
-rwxr-xr-xmod/poke.php2
-rw-r--r--mod/profiles.php2
-rwxr-xr-xmod/subthread.php2
-rw-r--r--mod/tagger.php2
-rw-r--r--version.inc2
17 files changed, 90 insertions, 137 deletions
diff --git a/README b/README
index 4cd2bced3..df465ed0a 100644
--- a/README
+++ b/README
@@ -1,8 +1,10 @@
-Friendica RED Social Communications Server
-==========================================
+Friendica RED Interaction Engine
+================================
-http://friendica.com
+Red is a new concept in electronic communications which is based on our earlier work with Friendica and our pioneering developments in decentralised, federated social networking.
-Welcome to the free social web.
+Red is prototype code and does not currently function. This message will be changed when it approaches stability.
-Red is prototype code and does not currently function. This message will be changed when it approaches stability. \ No newline at end of file
+At its heart, Red is a decentralised collection of location agnostic info streams (e.g. "channels") which are attached to permission controlled web resources, and which have the ability to discover each other and interact.
+
+Social networking emulation is one form that these streams can take, but they can take many other forms - limited only by your magination.
diff --git a/boot.php b/boot.php
index ff4547720..266b45914 100644
--- a/boot.php
+++ b/boot.php
@@ -368,9 +368,11 @@ if(! class_exists('App')) {
class App {
public $account = null;
+
private $channel = null;
+ private $observer = null;
private $widgets = array();
-
+
public $language;
public $module_loaded = false;
public $query_string;
@@ -612,6 +614,15 @@ if(! class_exists('App')) {
return $this->channel;
}
+
+ function set_observer($xchan) {
+ $this->observer = $xchan;
+ }
+
+ function get_observer() {
+ return $this->observer;
+ }
+
function set_widget($title,$html, $location = 'aside') {
$this->widgets[] = array('title' => $title, 'html' => $html, 'location' => $location);
}
diff --git a/include/event.php b/include/event.php
index ea3631331..2d11c9cc8 100644
--- a/include/event.php
+++ b/include/event.php
@@ -209,7 +209,7 @@ function event_store($arr) {
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
$arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
- $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid']));
+ $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_message_id());
$arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0);
if($arr['cid'])
diff --git a/include/items.php b/include/items.php
index 07b941074..1bfc3044a 100755
--- a/include/items.php
+++ b/include/items.php
@@ -931,6 +931,7 @@ function item_store($arr,$force_parent = false) {
return 0;
}
+
if(x($arr, 'gravity'))
$arr['gravity'] = intval($arr['gravity']);
elseif($arr['parent_uri'] === $arr['uri'])
@@ -964,14 +965,11 @@ function item_store($arr,$force_parent = false) {
$arr['body'] = strip_tags($arr['body']);
+ $arr['aid'] = ((x($arr,'aid')) ? intval($arr['aid']) : 0);
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string());
- $arr['author-name'] = ((x($arr,'author-name')) ? notags(trim($arr['author-name'])) : '');
- $arr['author-link'] = ((x($arr,'author-link')) ? notags(trim($arr['author-link'])) : '');
- $arr['author-avatar'] = ((x($arr,'author-avatar')) ? notags(trim($arr['author-avatar'])) : '');
- $arr['owner-name'] = ((x($arr,'owner-name')) ? notags(trim($arr['owner-name'])) : '');
- $arr['owner-link'] = ((x($arr,'owner-link')) ? notags(trim($arr['owner-link'])) : '');
- $arr['owner-avatar'] = ((x($arr,'owner-avatar')) ? notags(trim($arr['owner-avatar'])) : '');
+ $arr['author_xchan'] = ((x($arr,'author_xchan')) ? notags(trim($arr['author_xchan'])) : '');
+ $arr['owner_xchan'] = ((x($arr,'owner_xchan')) ? notags(trim($arr['owner_xchan'])) : '');
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
$arr['commented'] = datetime_convert();
diff --git a/include/security.php b/include/security.php
index a85787588..da58a65c3 100644
--- a/include/security.php
+++ b/include/security.php
@@ -25,32 +25,13 @@ function authenticate_success($user_record, $login_initial = false, $interactive
}
- $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid']))) ? intval($_SESSION['uid']) : 0);
- if(! $uid_to_load)
- $uid_to_load = intval($a->account['account_default_channel']);
+ $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid'])))
+ ? intval($_SESSION['uid'])
+ : intval($a->account['account_default_channel'])
+ );
if($uid_to_load) {
- $r = q("select * from channel where channel_id = %d and channel_account_id = %d limit 1",
- intval($uid_to_load),
- intval($a->account['account_id'])
- );
- if($r && count($r)) {
- $_SESSION['uid'] = intval($r[0]['channel_id']);
- $a->set_channel($r[0]);
- $_SESSION['theme'] = $r[0]['channel_theme'];
- date_default_timezone_set($r[0]['channel_timezone']);
- }
-
- $c = q("SELECT * FROM contact WHERE uid = %d AND self = 1 LIMIT 1",
- intval($r[0]['channel_id'])
- );
-
- if($c && count($c)) {
- $a->contact = $c[0];
- $a->cid = $c[0]['id'];
- $_SESSION['cid'] = $a->cid;
- }
-
+ change_channel($uid_to_load);
}
}
@@ -222,7 +203,7 @@ function can_write_wall(&$a,$owner) {
function change_channel($change_channel) {
- $r = false;
+ $ret = false;
if($change_channel) {
$r = q("select * from channel where channel_id = %d and channel_account_id = %d limit 1",
@@ -230,14 +211,21 @@ function change_channel($change_channel) {
intval(get_account_id())
);
if($r && count($r)) {
+ $hash = $r[0]['channel_hash'];
$_SESSION['uid'] = intval($r[0]['channel_id']);
get_app()->set_channel($r[0]);
$_SESSION['theme'] = $r[0]['channel_theme'];
date_default_timezone_set($r[0]['channel_timezone']);
+ $ret = $r[0];
}
+ $x = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($hash)
+ );
+ if($x && count($x))
+ get_app()->set_observer($x[0]);
}
- return $r;
+ return $ret;
}
diff --git a/include/text.php b/include/text.php
index d0ad414fa..a68782f2a 100644
--- a/include/text.php
+++ b/include/text.php
@@ -352,14 +352,14 @@ function perms2str($p) {
// generate a guaranteed unique (for this domain) item ID for ATOM
// safe from birthday paradox
-if(! function_exists('item_new_uri')) {
-function item_new_uri($hostname,$uid) {
+if(! function_exists('item_message_id')) {
+function item_message_id() {
do {
$dups = false;
$hash = random_string();
- $uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash;
+ $uri = $hash . '@' . $hostname;
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($uri));
diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
index b0bea7a61..c91b05a48 100644
--- a/mod/dfrn_confirm.php
+++ b/mod/dfrn_confirm.php
@@ -439,7 +439,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if(count($self)) {
$arr = array();
- $arr['uri'] = $arr['parent_uri'] = item_new_uri($a->get_hostname(), $uid);
+ $arr['uri'] = $arr['parent_uri'] = item_message_id();
$arr['uid'] = $uid;
$arr['contact-id'] = $self[0]['id'];
$arr['wall'] = 1;
@@ -760,7 +760,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if(count($self)) {
$arr = array();
- $arr['uri'] = $arr['parent_uri'] = item_new_uri($a->get_hostname(), $local_uid);
+ $arr['uri'] = $arr['parent_uri'] = item_message_id();
$arr['uid'] = $local_uid;
$arr['contact-id'] = $self[0]['id'];
$arr['wall'] = 1;
diff --git a/mod/item.php b/mod/item.php
index b135a4b3a..857d7ec63 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -18,6 +18,7 @@
require_once('include/crypto.php');
require_once('include/enotify.php');
require_once('include/email.php');
+require_once('include/items.php');
function item_post(&$a) {
@@ -173,14 +174,28 @@ function item_post(&$a) {
$orig_post = $i[0];
}
- $user = null;
+ $channel = null;
+
+ if(local_user() && local_user() == $profile_uid) {
+ $channel = $a->get_channel();
+ $observer = $a->get_observer();
+ }
+ else {
+ $r = q("SELECT channel.*, account.* FROM channel left join account on channel.channel_account_id = account.account_id
+ where channel.channel_id = %d LIMIT 1",
+ intval($profile_uid)
+ );
+ if(count($r))
+ $channel = $r[0];
+ }
+
+ if(! $channel) {
+ logger("mod_item: no channel.");
+ if(x($_REQUEST,'return'))
+ goaway($a->get_baseurl() . "/" . $return_path );
+ killme();
+ }
- $r = q("SELECT channel.*, account.* FROM channel left join account on channel.channel_account_id = account.account_id
- where channel.channel_id = %d LIMIT 1",
- intval($profile_uid)
- );
- if(count($r))
- $channel = $r[0];
if($orig_post) {
$str_group_allow = $orig_post['allow_gid'];
@@ -538,7 +553,8 @@ function item_post(&$a) {
$notify_type = (($parent) ? 'comment-new' : 'wall-new' );
- $uri = item_new_uri($a->get_hostname(),$profile_uid);
+ $uri = item_message_id();
+
// Fallback so that we alway have a thr_parent
@@ -546,17 +562,19 @@ function item_post(&$a) {
$thr_parent = $uri;
$datarray = array();
+
+ if(! $parent)
+ $datarray['parent_uri'] = $uri;
+
+
+ $datarray['aid'] = get_account_id(); // fixme
+
$datarray['uid'] = $profile_uid;
$datarray['type'] = $post_type;
$datarray['wall'] = $wall;
$datarray['gravity'] = $gravity;
- $datarray['contact-id'] = $contact_id;
- $datarray['owner-name'] = $contact_record['name'];
- $datarray['owner-link'] = $contact_record['url'];
- $datarray['owner-avatar'] = $contact_record['thumb'];
- $datarray['author-name'] = $author['name'];
- $datarray['author-link'] = $author['url'];
- $datarray['author-avatar'] = $author['thumb'];
+ $datarray['owner_xchan'] = $observer['xchan_hash']; // fixme
+ $datarray['author_xchan'] = $observer['xchan_hash'];
$datarray['created'] = datetime_convert();
$datarray['edited'] = datetime_convert();
$datarray['commented'] = datetime_convert();
@@ -582,18 +600,6 @@ function item_post(&$a) {
$datarray['origin'] = $origin;
$datarray['moderated'] = $allow_moderated;
- /**
- * These fields are for the convenience of plugins...
- * 'self' if true indicates the owner is posting on their own wall
- * If parent is 0 it is a top-level post.
- */
-
- $datarray['parent'] = $parent;
- $datarray['self'] = $self;
-
-
- if($orig_post)
- $datarray['edit'] = true;
// preview mode - prepare the body for display and send it via json
@@ -671,54 +677,11 @@ function item_post(&$a) {
$post_id = 0;
- $r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
- `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr_parent`, `title`, `body`, `app`, `lang`, `location`, `coord`,
- `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `attach`,`origin`, `moderated`)
- VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', %d, %d )",
- intval($datarray['uid']),
- dbesc($datarray['type']),
- intval($datarray['wall']),
- intval($datarray['gravity']),
- intval($datarray['contact-id']),
- dbesc($datarray['owner-name']),
- dbesc($datarray['owner-link']),
- dbesc($datarray['owner-avatar']),
- dbesc($datarray['author-name']),
- dbesc($datarray['author-link']),
- dbesc($datarray['author-avatar']),
- dbesc($datarray['created']),
- dbesc($datarray['edited']),
- dbesc($datarray['commented']),
- dbesc($datarray['received']),
- dbesc($datarray['changed']),
- dbesc($datarray['uri']),
- dbesc($datarray['thr_parent']),
- dbesc($datarray['title']),
- dbesc($datarray['body']),
- dbesc($datarray['app']),
- dbesc($datarray['lang']),
- dbesc($datarray['location']),
- dbesc($datarray['coord']),
- dbesc($datarray['inform']),
- dbesc($datarray['verb']),
- dbesc($datarray['postopts']),
- dbesc($datarray['allow_cid']),
- dbesc($datarray['allow_gid']),
- dbesc($datarray['deny_cid']),
- dbesc($datarray['deny_gid']),
- intval($datarray['private']),
- dbesc($datarray['attach']),
- intval($datarray['origin']),
- intval($datarray['moderated'])
- );
+ $post_id = item_store($datarray);
- $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
- dbesc($datarray['uri']));
- if(count($r)) {
- $post_id = $r[0]['id'];
+ if($post_id) {
logger('mod_item: saved item ' . $post_id);
-
if(count($post_tags)) {
foreach($post_tags as $tag) {
if(strlen(trim($tag['term']))) {
@@ -841,15 +804,6 @@ function item_post(&$a) {
call_hooks('post_local_end', $datarray);
- // This is a real juggling act on shared hosting services which kill your processes
- // e.g. dreamhost. We used to start delivery to our native delivery agents in the background
- // and then run our plugin delivery from the foreground. We're now doing plugin delivery first,
- // because as soon as you start loading up a bunch of remote delivey processes, *this* page is
- // likely to get killed off. If you end up looking at an /item URL and a blank page,
- // it's very likely the delivery got killed before all your friends could be notified.
- // Currently the only realistic fixes are to use a reliable server - which precludes shared hosting,
- // or cut back on plugins which do remote deliveries.
-
proc_run('php', "include/notifier.php", $notify_type, "$post_id");
logger('post_complete');
diff --git a/mod/like.php b/mod/like.php
index 7ee9c3cb0..a54493bb4 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -127,7 +127,7 @@ function like_content(&$a) {
return;
}
- $uri = item_new_uri($a->get_hostname(),$owner_uid);
+ $uri = item_message_id();
$post_type = (($item['resource_id']) ? t('photo') : t('status'));
$objtype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
diff --git a/mod/manage.php b/mod/manage.php
index 593ba4ae2..557a19375 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -14,8 +14,8 @@ function manage_content(&$a) {
if($change_channel) {
$r = change_channel($change_channel);
- if($r && $r[0]['channel_startpage'])
- goaway(z_root() . '/' . $r[0]['channel_startpage']);
+ if($r && $r['channel_startpage'])
+ goaway(z_root() . '/' . $r['channel_startpage']);
goaway(z_root());
}
diff --git a/mod/mood.php b/mod/mood.php
index 7a793c71e..8992c55e3 100755
--- a/mod/mood.php
+++ b/mod/mood.php
@@ -57,7 +57,7 @@ function mood_init(&$a) {
$poster = $a->contact;
- $uri = item_new_uri($a->get_hostname(),$uid);
+ $uri = item_message_id();
$action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
diff --git a/mod/photos.php b/mod/photos.php
index 25e04d79c..350b4bcd5 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -405,7 +405,7 @@ function photos_post(&$a) {
// Create item container
$title = '';
- $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
+ $uri = item_message_id();
$arr = array();
@@ -588,7 +588,7 @@ function photos_post(&$a) {
if(count($taginfo)) {
foreach($taginfo as $tagged) {
- $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
+ $uri = item_message_id();
$arr = array();
@@ -805,7 +805,7 @@ function photos_post(&$a) {
}
$basename = basename($filename);
- $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
+ $uri = item_message_id();
// Create item container
diff --git a/mod/poke.php b/mod/poke.php
index a4ccc517a..739690386 100755
--- a/mod/poke.php
+++ b/mod/poke.php
@@ -76,7 +76,7 @@ function poke_init(&$a) {
$poster = $a->contact;
- $uri = item_new_uri($a->get_hostname(),$uid);
+ $uri = item_message_id();
$arr = array();
diff --git a/mod/profiles.php b/mod/profiles.php
index 8679f3026..6c33deb0f 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -338,7 +338,7 @@ function profile_activity($changed, $value) {
return;
$arr = array();
- $arr['uri'] = $arr['parent_uri'] = item_new_uri($a->get_hostname(), local_user());
+ $arr['uri'] = $arr['parent_uri'] = item_message_id();
$arr['uid'] = local_user();
$arr['contact-id'] = $self[0]['id'];
$arr['wall'] = 1;
diff --git a/mod/subthread.php b/mod/subthread.php
index b6e8c476a..7ad7dfd6b 100755
--- a/mod/subthread.php
+++ b/mod/subthread.php
@@ -82,7 +82,7 @@ function subthread_content(&$a) {
return;
}
- $uri = item_new_uri($a->get_hostname(),$owner_uid);
+ $uri = item_message_id();
$post_type = (($item['resource_id']) ? t('photo') : t('status'));
$objtype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
diff --git a/mod/tagger.php b/mod/tagger.php
index bf05d2e4c..11d1f81d7 100644
--- a/mod/tagger.php
+++ b/mod/tagger.php
@@ -57,7 +57,7 @@ function tagger_content(&$a) {
return;
}
- $uri = item_new_uri($a->get_hostname(),$owner_uid);
+ $uri = item_message_id();
$xterm = xmlify($term);
$post_type = (($item['resource_id']) ? t('photo') : t('status'));
$targettype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
diff --git a/version.inc b/version.inc
index 819ec2494..612022b77 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-10-01.94
+2012-10-03.96