diff --git a/images/pencil.gif b/images/pencil.gif new file mode 100644 index 0000000000..26bfb0c9a4 Binary files /dev/null and b/images/pencil.gif differ diff --git a/mod/editpost.php b/mod/editpost.php new file mode 100644 index 0000000000..862ba937f0 --- /dev/null +++ b/mod/editpost.php @@ -0,0 +1,91 @@ +argc > 1) ? intval($a->argv[1]) : 0); + + if(! $post_id) { + notice( t('Item not found') . EOL); + return; + } + + $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($post_id), + intval(local_user()) + ); + + if(! count($r)) { + notice( t('Item not found') . EOL); + return; + } + + + $o .= '

' . t('Edit post') . '

'; + + $tpl = load_view_file('view/jot-header.tpl'); + + $a->page['htmlhead'] .= replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), + '$geotag' => $geotag, + '$nickname' => $a->user['nickname'] + )); + + + $tpl = load_view_file("view/jot.tpl"); + + if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) + $lockstate = 'lock'; + else + $lockstate = 'unlock'; + + $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); + + $jotplugins = ''; + $jotnets = ''; + call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); + + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); + + $o .= replace_macros($tpl,array( + '$return_path' => $_SESSION['return_url'], + '$action' => 'item', + '$share' => t('Edit'), + '$upload' => t('Upload photo'), + '$weblink' => t('Insert web link'), + '$youtube' => t('Insert YouTube video'), + '$video' => t('Insert Vorbis [.ogg] video'), + '$audio' => t('Insert Vorbis [.ogg] audio'), + '$setloc' => t('Set your location'), + '$noloc' => t('Clear browser location'), + '$wait' => t('Please wait'), + '$permset' => t('Permission settings'), + '$content' => $r[0]['body'], + '$post_id' => $post_id, + '$baseurl' => $a->get_baseurl(), + '$defloc' => $a->user['default-location'], + '$visitor' => 'none', + '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, + '$emtitle' => t('Example: bob@example.com, mary@example.com'), + '$lockstate' => $lockstate, + '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user), $celeb), + '$bang' => (($group) ? '!' : ''), + '$profile_uid' => $_SESSION['uid'] + )); + + + return $o; + +} + + diff --git a/mod/item.php b/mod/item.php index 6e6e822d0c..511e268093 100644 --- a/mod/item.php +++ b/mod/item.php @@ -51,7 +51,7 @@ function item_post(&$a) { } $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0); - + $post_id = ((x($_POST['post_id'])) ? intval($_POST['post_id']) : 0); if(! can_write_wall($a,$profile_uid)) { notice( t('Permission denied.') . EOL) ; @@ -151,6 +151,35 @@ function item_post(&$a) { } } + // is this an edited post? + + $orig_post = null; + + if($post_id) { + $i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", + intval($profile_uid), + intval($post_id) + ); + if(! count($i)) + killme(); + $orig_post = $i[0]; + } + + if($orig_post) { + $str_group_allow = $orig_post['allow_gid']; + $str_contact_allow = $orig_post['allow_cid']; + $str_group_deny = $orig_post['deny_gid']; + $str_contact_deny = $orig_post['deny_cid']; + $private = $orig_post['private']; + $title = $orig_post['title']; + $location = $orig_post['location']; + $coord = $orig_post['coord']; + $verb = $orig_post['verb']; + $emailcc = $orig_post['emailcc']; + + $body = escape_tags(trim($_POST['body'])); + } + /** * @@ -294,8 +323,25 @@ function item_post(&$a) { } + if($orig_post) { + $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc($body), + dbesc(datetime_convert()), + intval($post_id), + intval($profile_uid) + ); + proc_run('php', "include/notifier.php", 'edit_post', "$post_id"); + if((x($_POST,'return')) && strlen($_POST['return'])) { + logger('return: ' . $_POST['return']); + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + } + killme(); + } + + $post_id = 0; $wall = 0; + if($post_type === 'wall' || $post_type === 'wall-comment') $wall = 1; diff --git a/mod/network.php b/mod/network.php index abdf59c486..81c85f0ff7 100644 --- a/mod/network.php +++ b/mod/network.php @@ -387,6 +387,9 @@ function network_content(&$a, $update = 0) { )); } + $edpost = ''; + if(($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + $edpost = ''; $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete'))); $photo = $item['photo']; @@ -455,6 +458,7 @@ function network_content(&$a, $update = 0) { '$owner_photo' => $owner_photo, '$owner_name' => $owner_name, '$plink' => get_plink($item), + '$edpost' => $edpost, '$drop' => $drop, '$vote' => $likebuttons, '$like' => $like, diff --git a/mod/profile.php b/mod/profile.php index c0989bd28a..1053e4a1e6 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -348,6 +348,12 @@ function profile_content(&$a, $update = 0) { else $sparkle = ''; + + $edpost = ''; + if((local_user()) && ($a->profile['profile_uid'] == local_user()) && ($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + $edpost = ''; + + // We would prefer to use our own avatar link for this item because the one in the author-avatar might reference a // remote site (which could be down). We will use author-avatar if we haven't got something stored locally. // We use this same logic block in mod/network.php to determine it this is a third party post and we don't have any @@ -400,6 +406,7 @@ function profile_content(&$a, $update = 0) { '$location' => $location, '$indent' => $indent, '$plink' => get_plink($item), + '$edpost' => $edpost, '$drop' => $drop, '$like' => $like, '$vote' => $likebuttons, diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index ce75655fb9..5db45921ad 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -927,6 +927,10 @@ input#dfrn-url { margin-left: 10px; } +.editpost { + margin-left: 15px; +} + .wall-item-links-wrapper { float: left; } diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index 1c378793ad..0284bdcf86 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -999,6 +999,10 @@ input#dfrn-url { margin-left: 5px; } +.editpost { + margin-left: 15px; +} + .wall-item-links-wrapper { float: left; } diff --git a/view/wall_item.tpl b/view/wall_item.tpl index 5cae6b1424..4c2a3fbf42 100644 --- a/view/wall_item.tpl +++ b/view/wall_item.tpl @@ -24,6 +24,7 @@
$vote $plink + $edpost $drop
diff --git a/view/wallwall_item.tpl b/view/wallwall_item.tpl index 256320a46d..60383d8854 100644 --- a/view/wallwall_item.tpl +++ b/view/wallwall_item.tpl @@ -28,6 +28,7 @@
$vote $plink + $edpost $drop