aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/editpost.php91
-rw-r--r--mod/item.php48
-rw-r--r--mod/network.php4
-rw-r--r--mod/profile.php7
4 files changed, 149 insertions, 1 deletions
diff --git a/mod/editpost.php b/mod/editpost.php
new file mode 100644
index 000000000..862ba937f
--- /dev/null
+++ b/mod/editpost.php
@@ -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;
+
+}
+
+
diff --git a/mod/item.php b/mod/item.php
index 6e6e822d0..511e26809 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 abdf59c48..81c85f0ff 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 = '<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,
diff --git a/mod/profile.php b/mod/profile.php
index c0989bd28..1053e4a1e 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 = '<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,