aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-03 22:28:19 -0700
committerfriendica <info@friendica.com>2012-10-03 22:28:19 -0700
commite124c9fa5ca046d48eb927fe80706cf6d42f6bff (patch)
tree8df07cdd9a21c977bc961328cdc6a2f161a82988 /include
parentd0f62d1219d035d92f3adb717d9fdbed03fa6dd5 (diff)
downloadvolse-hubzilla-e124c9fa5ca046d48eb927fe80706cf6d42f6bff.tar.gz
volse-hubzilla-e124c9fa5ca046d48eb927fe80706cf6d42f6bff.tar.bz2
volse-hubzilla-e124c9fa5ca046d48eb927fe80706cf6d42f6bff.zip
Can't see any posts currently - after the big shakeup, but we can now post top level activities and store them.
Diffstat (limited to 'include')
-rw-r--r--include/event.php2
-rwxr-xr-xinclude/items.php10
-rw-r--r--include/security.php40
-rw-r--r--include/text.php6
4 files changed, 22 insertions, 36 deletions
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));