aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--database.sql8
-rw-r--r--include/event.php20
-rw-r--r--include/identity.php22
-rw-r--r--js/fk.autocomplete.js2
-rw-r--r--mod/display.php6
-rwxr-xr-xmod/events.php1
-rw-r--r--mod/item.php51
-rw-r--r--mod/profile.php47
-rw-r--r--mod/wall_attach.php2
-rw-r--r--version.inc2
10 files changed, 76 insertions, 85 deletions
diff --git a/database.sql b/database.sql
index 248502859..fc162833a 100644
--- a/database.sql
+++ b/database.sql
@@ -284,9 +284,10 @@ CREATE TABLE IF NOT EXISTS `deliverq` (
CREATE TABLE IF NOT EXISTS `event` (
`id` int(11) NOT NULL AUTO_INCREMENT,
+ `account` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(11) NOT NULL,
`cid` int(11) NOT NULL,
- `uri` char(255) NOT NULL,
+ `message_id` char(255) NOT NULL,
`created` datetime NOT NULL,
`edited` datetime NOT NULL,
`start` datetime NOT NULL,
@@ -305,13 +306,14 @@ CREATE TABLE IF NOT EXISTS `event` (
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `cid` (`cid`),
- KEY `uri` (`uri`),
+ KEY `uri` (`message_id`),
KEY `type` (`type`),
KEY `start` (`start`),
KEY `finish` (`finish`),
KEY `adjust` (`adjust`),
KEY `nofinish` (`nofinish`),
- KEY `ignore` (`ignore`)
+ KEY `ignore` (`ignore`),
+ KEY `account` (`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `fcontact` (
diff --git a/include/event.php b/include/event.php
index 2d11c9cc8..e4a01cf7d 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_message_id());
+ $arr['message_id'] = (x($arr,'message_id') ? $arr['message_id'] : get_message_id());
$arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0);
if($arr['cid'])
@@ -286,7 +286,7 @@ function event_store($arr) {
intval($arr['uid'])
);
if(count($r)) {
- $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
+ $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['message_id']) . '</id>';
$object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
$object .= '</object>' . "\n";
@@ -317,9 +317,10 @@ function event_store($arr) {
// New event. Store it.
- $r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
+ $r = q("INSERT INTO `event` ( `uid`,`account`,`cid`,`message_id`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
`adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
+ VALUES ( %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
+ intval($arr['account']),
intval($arr['uid']),
intval($arr['cid']),
dbesc($arr['uri']),
@@ -340,8 +341,8 @@ function event_store($arr) {
);
- $r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($arr['uri']),
+ $r = q("SELECT * FROM `event` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($arr['hash']),
intval($arr['uid'])
);
if(count($r))
@@ -349,10 +350,11 @@ function event_store($arr) {
$item_arr = array();
+
$item_arr['uid'] = $arr['uid'];
$item_arr['contact-id'] = $arr['cid'];
- $item_arr['uri'] = $arr['uri'];
- $item_arr['parent_uri'] = $arr['uri'];
+ $item_arr['uri'] = $arr['message_id'];
+ $item_arr['parent_uri'] = $arr['message_id'];
$item_arr['type'] = 'activity';
$item_arr['wall'] = (($arr['cid']) ? 0 : 1);
$item_arr['contact-id'] = $contact['id'];
@@ -376,7 +378,7 @@ function event_store($arr) {
$item_arr['body'] = format_event_bbcode($event);
- $item_arr['object'] = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
+ $item_arr['object'] = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['message_id']) . '</id>';
$item_arr['object'] .= '<content>' . xmlify(format_event_bbcode($event)) . '</content>';
$item_arr['object'] .= '</object>' . "\n";
diff --git a/include/identity.php b/include/identity.php
index 23ceb74ae..d8eb42ae7 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -110,14 +110,17 @@ function create_identity($arr) {
$newuid = $ret['channel']['channel_id'];
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_photo, xchan_addr, xchan_profile, xchan_name ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_photo, xchan_addr, xchan_profile, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
dbesc($hash),
dbesc($ret['channel']['channel_guid']),
dbesc($sig),
dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
dbesc($ret['channel']['channel_address'] . '@' . $a->get_hostname()),
dbesc(z_root() . '/profile/' . $ret['channel']['channel_address']),
- dbesc($ret['channel']['channel_name'])
+ dbesc($ret['channel']['channel_name']),
+ dbesc('zot'),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert())
);
// Not checking return value.
@@ -135,21 +138,6 @@ function create_identity($arr) {
dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}")
);
- $r = q("INSERT INTO `contact` ( `aid`, `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `name_date`, `uri_date`, `avatar_date`, `closeness` )
- VALUES ( %d, %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', 0 ) ",
- intval($ret['channel']['channel_account_id']),
- intval($newuid),
- datetime_convert(),
- dbesc($ret['channel']['channel_name']),
- dbesc($ret['channel']['channel_address']),
- dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
- dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}"),
- dbesc($a->get_baseurl() . "/photo/micro/{$newuid}"),
- dbesc($a->get_baseurl() . "/profile/{$ret['channel']['channel_address']}"),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- dbesc(datetime_convert())
- );
// Create a group with no members. This allows somebody to use it
// right away as a default group for new contacts.
diff --git a/js/fk.autocomplete.js b/js/fk.autocomplete.js
index b1db92c41..fc41f9cbe 100644
--- a/js/fk.autocomplete.js
+++ b/js/fk.autocomplete.js
@@ -104,7 +104,7 @@ ACPopup.prototype._search = function(){
else {
txt = tinyMCE.activeEditor.getContent();
// alert(that.searchText + ':' + t);
- newtxt = txt.replace(that.searchText,t+' ');
+ newtxt = txt.replace('@' + that.searchText, '@' + t + ' ');
tinyMCE.activeEditor.setContent(newtxt);
tinyMCE.activeEditor.focus();
that.close();
diff --git a/mod/display.php b/mod/display.php
index 8193ce377..80813e69e 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -97,11 +97,7 @@ function display_content(&$a) {
$sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
diff --git a/mod/events.php b/mod/events.php
index f950b5adc..e6ee19c47 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -106,6 +106,7 @@ function events_post(&$a) {
$datarray = array();
+ $datarray['hash'] = random_string();
$datarray['start'] = $start;
$datarray['finish'] = $finish;
$datarray['summary'] = $summary;
diff --git a/mod/item.php b/mod/item.php
index ae011d3c6..91923153e 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -310,6 +310,8 @@ function item_post(&$a) {
// get contact info for poster
+
+/*
$author = null;
$self = false;
$contact_id = 0;
@@ -355,6 +357,8 @@ function item_post(&$a) {
$contact_record = $r[0];
}
+*/
+
$post_type = notags(trim($_REQUEST['type']));
@@ -382,7 +386,7 @@ function item_post(&$a) {
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
if(! strlen($image_uri))
continue;
- $srch = '<' . intval($contact_id) . '>';
+ $srch = '<' . $owner_xchan['xchan_hash'] . '>';
$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
AND `resource_id` = '%s' AND `uid` = %d LIMIT 1",
@@ -421,19 +425,19 @@ function item_post(&$a) {
$attaches = $match[1];
if(count($attaches)) {
foreach($attaches as $attach) {
- $r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ $r = q("select * from attach where uid = %d and hash = '%s' limit 1",
intval($profile_uid),
- intval($attach)
+ dbesc($attach)
);
if(count($r)) {
$r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
- WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ WHERE `uid` = %d AND `hash` = '%s' LIMIT 1",
dbesc($str_contact_allow),
dbesc($str_group_allow),
dbesc($str_contact_deny),
dbesc($str_group_deny),
intval($profile_uid),
- intval($attach)
+ dbesc($attach)
);
}
}
@@ -486,11 +490,11 @@ function item_post(&$a) {
if($success['replaced']) {
$tagged[] = $tag;
$post_tags[] = array(
- 'uid' => $profile_uid,
- 'type' => $success['termtype'],
+ 'uid' => $profile_uid,
+ 'type' => $success['termtype'],
'otype' => TERM_OBJ_POST,
- 'term' => substr($tag,1),
- 'url' => $success['url']
+ 'term' => substr($tag,1),
+ 'url' => $success['url']
);
}
if(is_array($success['contact']) && intval($success['contact']['prv'])) {
@@ -504,11 +508,11 @@ function item_post(&$a) {
$cats = explode(',',$categories);
foreach($cats as $cat) {
$post_tags[] = array(
- 'uid' => $profile_uid,
- 'type' => TERM_CATEGORY,
+ 'uid' => $profile_uid,
+ 'type' => TERM_CATEGORY,
'otype' => TERM_OBJ_POST,
- 'term' => trim($cat),
- 'url' => ''
+ 'term' => trim($cat),
+ 'url' => ''
);
}
}
@@ -527,20 +531,20 @@ function item_post(&$a) {
if(preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
foreach($match[2] as $mtch) {
- $r = q("SELECT `id`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ $r = q("SELECT `hash`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `hash` = '%s' LIMIT 1",
intval($profile_uid),
- intval($mtch)
+ dbesc($mtch)
);
if(count($r)) {
if(strlen($attachments))
$attachments .= ',';
- $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
+ $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['hash'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
}
$body = str_replace($match[1],'',$body);
}
}
- $item_flags = 0;
+ $item_flags = ITEM_UNSEEN;
$item_restrict = ITEM_VISIBLE;
if($post_type === 'wall' || $post_type === 'wall-comment')
@@ -551,6 +555,8 @@ function item_post(&$a) {
if($moderated)
$item_restrict = $item_restrict | ITEM_MODERATED;
+
+
if(! strlen($verb))
@@ -573,8 +579,7 @@ function item_post(&$a) {
$item_flags = $item_flags | ITEM_THREAD_TOP;
}
- $datarray['aid'] = get_account_id(); // fixme
-
+ $datarray['aid'] = $channel['account_id'];
$datarray['uid'] = $profile_uid;
$datarray['owner_xchan'] = $owner_xchan['xchan_hash'];
@@ -601,11 +606,15 @@ function item_post(&$a) {
$datarray['attach'] = $attachments;
$datarray['thr_parent'] = $thr_parent;
$datarray['postopts'] = '';
+ $datarray['item_restrict'] = $item_restrict;
+ $datarray['item_flags'] = $item_flags;
+
// preview mode - prepare the body for display and send it via json
if($preview) {
require_once('include/conversation.php');
+// fixme
$o = conversation($a,array(array_merge($contact_record,$datarray)),'search',false,'preview');
logger('preview: ' . $o, LOGGER_DEBUG);
echo json_encode(array('preview' => $o));
@@ -716,7 +725,7 @@ function item_post(&$a) {
intval($parent_item['private']),
intval($post_id)
);
-
+//fixme
if($contact_record != $author) {
notification(array(
'type' => NOTIFY_COMMENT,
@@ -741,7 +750,7 @@ function item_post(&$a) {
}
else {
$parent = $post_id;
-
+//fixme
if($contact_record != $author) {
notification(array(
'type' => NOTIFY_WALL,
diff --git a/mod/profile.php b/mod/profile.php
index 2724771a7..b83dbdf3f 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -177,16 +177,13 @@ function profile_content(&$a, $update = 0) {
if($update) {
- $r = q("SELECT distinct(parent) AS `item_id`, `contact`.`uid` AS `contact-uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
- (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
- and `item`.`moderated` = 0 and `item`.`unseen` = 1
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`wall` = 1
+ $r = q("SELECT distinct(parent) AS `item_id` from item
+ WHERE uid = %d AND item_restrict = 0
+ AND item_flags & %d
$sql_extra
- ORDER BY `item`.`created` DESC",
- intval($a->profile['profile_uid'])
+ ORDER BY created DESC",
+ intval($a->profile['profile_uid']),
+ intval(ITEM_WALL)
);
}
@@ -208,14 +205,13 @@ function profile_content(&$a, $update = 0) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
- $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
+ $r = q("SELECT id AS item_id FROM item
+ WHERE uid = %d AND item_restrict = 0
+ AND item_flags & %d
$sql_extra $sql_extra2
- ORDER BY `item`.`created` DESC $pager_sql ",
- intval($a->profile['profile_uid'])
+ ORDER BY created DESC $pager_sql ",
+ intval($a->profile['profile_uid']),
+ intval(ITEM_WALL|ITEM_THREAD_TOP)
);
@@ -225,21 +221,16 @@ function profile_content(&$a, $update = 0) {
$parents_str = ids_to_querystr($r,'item_id');
- $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,
- `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, `contact`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- and `item`.`moderated` = 0
- AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $items = q("SELECT `item`.*, `item`.`id` AS `item_id`
+ FROM `item`
+ WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
AND `item`.`parent` IN ( %s )
$sql_extra ",
intval($a->profile['profile_uid']),
dbesc($parents_str)
);
+ xchan_query($items);
$items = fetch_post_tags($items);
$items = conv_sort($items,'created');
@@ -260,8 +251,10 @@ function profile_content(&$a, $update = 0) {
if($is_owner) {
- $r = q("UPDATE `item` SET `unseen` = 0
- WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
+ $r = q("UPDATE `item` SET `item_flags` = item_flags - %d
+ WHERE item_flags & %d AND `uid` = %d",
+ intval(ITEM_UNSEEN),
+ intval(ITEM_UNSEEN|ITEM_WALL),
intval(local_user())
);
}
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index c23efc786..b32e2b877 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -127,7 +127,7 @@ function wall_attach_post(&$a) {
if(local_user() && intval(get_pconfig(local_user(),'system','plaintext')))
$lf = "\n";
- echo $lf . $lf . '[attachment]' . $r[0]['id'] . '[/attachment]' . $lf;
+ echo $lf . $lf . '[attachment]' . $r[0]['hash'] . '[/attachment]' . $lf;
killme();
// NOTREACHED
diff --git a/version.inc b/version.inc
index 0e8c2c404..86aa538ef 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-10-08.101
+2012-10-10.103