]> git.mxchange.org Git - friendica.git/commitdiff
edit posting after submission
authorFriendika <info@friendika.com>
Fri, 18 Mar 2011 07:30:34 +0000 (00:30 -0700)
committerFriendika <info@friendika.com>
Fri, 18 Mar 2011 07:30:34 +0000 (00:30 -0700)
images/pencil.gif [new file with mode: 0644]
mod/editpost.php [new file with mode: 0644]
mod/item.php
mod/network.php
mod/profile.php
view/theme/duepuntozero/style.css
view/theme/loozah/style.css
view/wall_item.tpl
view/wallwall_item.tpl

diff --git a/images/pencil.gif b/images/pencil.gif
new file mode 100644 (file)
index 0000000..26bfb0c
Binary files /dev/null and b/images/pencil.gif differ
diff --git a/mod/editpost.php b/mod/editpost.php
new file mode 100644 (file)
index 0000000..862ba93
--- /dev/null
@@ -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;
+
+}
+
+
index 6e6e822d0cfe1ac9d973f864141837499be8f6f1..511e268093cea04a1f3f7f85c4a6f2192bf85b30 100644 (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;
 
index abdf59c4869fc6ae0d268c3fd7dfeedb6b733f6c..81c85f0ff7645c9989ba0ab13b756df53b93e172 100644 (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,
index c0989bd28a253dc43a17aeeb462b4b3c7b457098..1053e4a1e643a060313ff79bfce14106e56da8fb 100644 (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,
index ce75655fb9dd38e0721bcfba37fdb48f1c9f6748..5db45921adda412dd8e1050aea52d819c6b3544b 100644 (file)
@@ -927,6 +927,10 @@ input#dfrn-url {
        margin-left: 10px;
 }
 
+.editpost {
+       margin-left: 15px;
+}
+
 .wall-item-links-wrapper {
        float: left;
 }
index 1c378793ad77269429027c4c59a3bdee4ec8ca2c..0284bdcf866e76903e013fa057fbfb9b8bf67a88 100644 (file)
@@ -999,6 +999,10 @@ input#dfrn-url {
        margin-left: 5px;
 }
 
+.editpost {
+       margin-left: 15px;
+}
+
 .wall-item-links-wrapper {
     float: left;
 }
index 5cae6b1424c7b750e1ab5c2435a0bb0531d6f9f3..4c2a3fbf42b39d1204cb9c60c8b259297303e988 100644 (file)
@@ -24,6 +24,7 @@
                <div class="wall-item-tools" id="wall-item-tools-$id">
                $vote
                $plink
+               $edpost
                $drop
                </div>
        </div>
index 256320a46dac11bf7e3b04f76f442db34b3a18e7..60383d885426222c3bd153a23911529c4b37ce16 100644 (file)
@@ -28,6 +28,7 @@
                <div class="wall-item-tools" id="wall-item-tools-$id">
                $vote
                $plink
+               $edpost
                $drop
                </div>
        </div>