edit posting after submission

This commit is contained in:
Friendika 2011-03-18 00:30:34 -07:00
parent ea03d9fa86
commit 9f5201dcaa
9 changed files with 159 additions and 1 deletions

BIN
images/pencil.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

91
mod/editpost.php Normal file
View File

@ -0,0 +1,91 @@
<?php
require_once('acl_selectors.php');
function editpost_content(&$a) {
$o = '';
if(! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$post_id = (($a->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 .= '<h2>' . t('Edit post') . '</h2>';
$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;
}

View File

@ -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;

View File

@ -387,6 +387,9 @@ function network_content(&$a, $update = 0) {
));
}
$edpost = '';
if(($item['id'] == $item['parent']) && (intval($item['wall']) == 1))
$edpost = '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>';
$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,

View File

@ -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 = '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>';
// 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,

View File

@ -927,6 +927,10 @@ input#dfrn-url {
margin-left: 10px;
}
.editpost {
margin-left: 15px;
}
.wall-item-links-wrapper {
float: left;
}

View File

@ -999,6 +999,10 @@ input#dfrn-url {
margin-left: 5px;
}
.editpost {
margin-left: 15px;
}
.wall-item-links-wrapper {
float: left;
}

View File

@ -24,6 +24,7 @@
<div class="wall-item-tools" id="wall-item-tools-$id">
$vote
$plink
$edpost
$drop
</div>
</div>

View File

@ -28,6 +28,7 @@
<div class="wall-item-tools" id="wall-item-tools-$id">
$vote
$plink
$edpost
$drop
</div>
</div>