diff options
author | friendica <info@friendica.com> | 2012-10-10 17:58:56 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-10-10 17:58:56 -0700 |
commit | 794c92a8fb789f604c869e9adabf5aae24cd90d6 (patch) | |
tree | a9a905f2729ef70d19e62bea2b2849a05230670b /mod | |
parent | 602960460a6206f20ec9cb69b3f5214391b8ddc4 (diff) | |
download | volse-hubzilla-794c92a8fb789f604c869e9adabf5aae24cd90d6.tar.gz volse-hubzilla-794c92a8fb789f604c869e9adabf5aae24cd90d6.tar.bz2 volse-hubzilla-794c92a8fb789f604c869e9adabf5aae24cd90d6.zip |
wall posts now display - address book structure revamp started
Diffstat (limited to 'mod')
-rw-r--r-- | mod/display.php | 6 | ||||
-rwxr-xr-x | mod/events.php | 1 | ||||
-rw-r--r-- | mod/item.php | 51 | ||||
-rw-r--r-- | mod/profile.php | 47 | ||||
-rw-r--r-- | mod/wall_attach.php | 2 |
5 files changed, 53 insertions, 54 deletions
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 |