]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #7044 from MrPetovan/task/router
authorPhilipp <admin+Github@philipp.info>
Thu, 2 May 2019 16:26:30 +0000 (18:26 +0200)
committerGitHub <noreply@github.com>
Thu, 2 May 2019 16:26:30 +0000 (18:26 +0200)
Move mod/admin to src/Module/Admin

19 files changed:
mod/hcard.php
mod/notice.php
mod/photos.php
mod/suggest.php
mod/videos.php
mod/viewsrc.php
src/App.php
src/Model/Profile.php
view/templates/album_edit.tpl
view/templates/photo_album.tpl
view/templates/photo_edit.tpl
view/templates/photo_view.tpl
view/theme/frio/js/mod_photos.js
view/theme/frio/templates/album_edit.tpl
view/theme/frio/templates/confirm.tpl
view/theme/frio/templates/photo_album.tpl
view/theme/frio/templates/photo_view.tpl
view/theme/quattro/templates/photo_view.tpl
view/theme/vier/templates/photo_view.tpl

index cbaebc8ff4819f558a42983c380dddf9cf39d37e..e27ea29be4b0f8bc5c3e645aee2a38619a8deda9 100644 (file)
@@ -18,7 +18,6 @@ function hcard_init(App $a)
                $which = $a->argv[1];
        } else {
                notice(L10n::t('No profile') . EOL);
-               $a->error = 404;
                return;
        }
 
index 1a584000c72d86eee8560391b8c6ad910033bdf9..edcbefdad2321d1e3515566e94f217fa3c4d9a33 100644 (file)
@@ -16,7 +16,6 @@ function notice_init(App $a)
                $nick = $r[0]['nickname'];
                $a->internalRedirect('display/' . $nick . '/' . $id);
        } else {
-               $a->error = 404;
                notice(L10n::t('Item not found.') . EOL);
        }
 
index a8160bd4c668d6e81abd547e3070b701a7bf76b3..db9beb6685fa8e712386ca830700a3983c75cfce 100644 (file)
@@ -47,16 +47,14 @@ function photos_init(App $a) {
 
        if ($a->argc > 1) {
                $nick = $a->argv[1];
-               $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
-                       DBA::escape($nick)
-               );
+               $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
 
                if (!DBA::isResult($user)) {
                        return;
                }
 
-               $a->data['user'] = $user[0];
-               $a->profile_uid = $user[0]['uid'];
+               $a->data['user'] = $user;
+               $a->profile_uid = $user['uid'];
                $is_owner = (local_user() && (local_user() == $a->profile_uid));
 
                $profile = Profile::getByNickname($nick, $a->profile_uid);
@@ -169,12 +167,7 @@ function photos_post(App $a)
                }
 
                if ($contact_id > 0) {
-                       $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
-                               intval($contact_id),
-                               intval($page_owner_uid)
-                       );
-
-                       if (DBA::isResult($r)) {
+                       if (DBA::exists('contact', ['id' => $contact_id, 'uid' => $page_owner_uid, 'blocked' => false, 'pending' => false])) {
                                $can_post = true;
                                $visitor = $contact_id;
                        }
@@ -234,36 +227,12 @@ function photos_post(App $a)
                }
 
                /*
-                * DELETE photo album and all its photos
+                * DELETE all photos filed in a given album
                 */
-
-               if ($_POST['dropalbum'] == L10n::t('Delete Album')) {
-                       // Check if we should do HTML-based delete confirmation
-                       if (!empty($_REQUEST['confirm'])) {
-                               $drop_url = $a->query_string;
-
-                               $extra_inputs = [
-                                       ['name' => 'albumname', 'value' => $_POST['albumname']],
-                               ];
-
-                               $a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
-                                       '$method' => 'post',
-                                       '$message' => L10n::t('Do you really want to delete this photo album and all its photos?'),
-                                       '$extra_inputs' => $extra_inputs,
-                                       '$confirm' => L10n::t('Delete Album'),
-                                       '$confirm_url' => $drop_url,
-                                       '$confirm_name' => 'dropalbum', // Needed so that confirmation will bring us back into this if statement
-                                       '$cancel' => L10n::t('Cancel'),
-                               ]);
-
-                               $a->error = 1; // Set $a->error so the other module functions don't execute
-                               return;
-                       }
-
+               if (!empty($_POST['dropalbum'])) {
                        $res = [];
 
                        // get the list of photos we are about to delete
-
                        if ($visitor) {
                                $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `album` = '%s'",
                                        intval($visitor),
@@ -281,77 +250,57 @@ function photos_post(App $a)
                                foreach ($r as $rr) {
                                        $res[] = $rr['rid'];
                                }
-                       } else {
-                               $a->internalRedirect($_SESSION['photo_return']);
-                               return; // NOTREACHED
-                       }
 
-                       // remove the associated photos
-                       Photo::delete(['resource-id' => $res, 'uid' => $page_owner_uid]);
+                               // remove the associated photos
+                               Photo::delete(['resource-id' => $res, 'uid' => $page_owner_uid]);
 
-                       // find and delete the corresponding item with all the comments and likes/dislikes
-                       Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
+                               // find and delete the corresponding item with all the comments and likes/dislikes
+                               Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
 
-                       // Update the photo albums cache
-                       Photo::clearAlbumCache($page_owner_uid);
+                               // Update the photo albums cache
+                               Photo::clearAlbumCache($page_owner_uid);
+                               notice(L10n::t('Album successfully deleted'));
+                       } else {
+                               notice(L10n::t('Album was empty.'));
+                       }
                }
 
-               $a->internalRedirect('photos/' . $a->data['user']['nickname']);
-               return; // NOTREACHED
+               $a->internalRedirect('photos/' . $a->argv[1]);
        }
 
+       if ($a->argc > 3 && $a->argv[2] === 'image') {
+               // Check if the user has responded to a delete confirmation query for a single photo
+               if (!empty($_POST['canceled'])) {
+                       $a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
+               }
 
-       // Check if the user has responded to a delete confirmation query for a single photo
-       if ($a->argc > 2 && !empty($_REQUEST['canceled'])) {
-               $a->internalRedirect($_SESSION['photo_return']);
-       }
-
-       if ($a->argc > 2 && defaults($_POST, 'delete', '') === L10n::t('Delete Photo')) {
-
-               // same as above but remove single photo
-
-               // Check if we should do HTML-based delete confirmation
-               if (!empty($_REQUEST['confirm'])) {
-                       $drop_url = $a->query_string;
+               if (!empty($_POST['delete'])) {
+                       // same as above but remove single photo
+                       if ($visitor) {
+                               $condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => $a->argv[3]];
 
-                       $a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
-                               '$method' => 'post',
-                               '$message' => L10n::t('Do you really want to delete this photo?'),
-                               '$extra_inputs' => [],
-                               '$confirm' => L10n::t('Delete Photo'),
-                               '$confirm_url' => $drop_url,
-                               '$confirm_name' => 'delete', // Needed so that confirmation will bring us back into this if statement
-                               '$cancel' => L10n::t('Cancel'),
-                       ]);
+                       } else {
+                               $condition = ['uid' => local_user(), 'resource-id' => $a->argv[3]];
+                       }
 
-                       $a->error = 1; // Set $a->error so the other module functions don't execute
-                       return;
-               }
+                       $photo = DBA::selectFirst('photo', ['resource-id'], $condition);
 
-               if ($visitor) {
-                       $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `resource-id` = '%s' LIMIT 1",
-                               intval($visitor),
-                               intval($page_owner_uid),
-                               DBA::escape($a->argv[2])
-                       );
-               } else {
-                       $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
-                               intval(local_user()),
-                               DBA::escape($a->argv[2])
-                       );
-               }
+                       if (DBA::isResult($photo)) {
+                               Photo::delete(['uid' => $page_owner_uid, 'resource-id' => $photo['resource-id']]);
 
-               if (DBA::isResult($r)) {
-                       Photo::delete(['uid' => $page_owner_uid, 'resource-id' => $r[0]['resource-id']]);
+                               Item::deleteForUser(['resource-id' => $photo['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
 
-                       Item::deleteForUser(['resource-id' => $r[0]['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
+                               // Update the photo albums cache
+                               Photo::clearAlbumCache($page_owner_uid);
+                               notice('Successfully deleted the photo.');
+                       } else {
+                               notice('Failed to delete the photo.');
+                               $a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
+                       }
 
-                       // Update the photo albums cache
-                       Photo::clearAlbumCache($page_owner_uid);
+                       $a->internalRedirect('photos/' . $a->argv[1]);
+                       return; // NOTREACHED
                }
-
-               $a->internalRedirect('photos/' . $a->data['user']['nickname']);
-               return; // NOTREACHED
        }
 
        if ($a->argc > 2 && (!empty($_POST['desc']) || !empty($_POST['newtag']) || isset($_POST['albname']))) {
@@ -492,6 +441,7 @@ function photos_post(App $a)
                                foreach ($tags as $tag) {
                                        if (strpos($tag, '@') === 0) {
                                                $profile = '';
+                                               $contact = null;
                                                $name = substr($tag,1);
 
                                                if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
@@ -526,34 +476,26 @@ function photos_post(App $a)
                                                        }
 
                                                        if ($tagcid) {
-                                                               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                                                                       intval($tagcid),
-                                                                       intval($page_owner_uid)
-                                                               );
+                                                               $contact = DBA::selectFirst('contact', [], ['id' => $tagcid, 'uid' => $page_owner_uid]);
                                                        } else {
                                                                $newname = str_replace('_',' ',$name);
 
                                                                //select someone from this user's contacts by name
-                                                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
-                                                                               DBA::escape($newname),
-                                                                               intval($page_owner_uid)
-                                                               );
-
-                                                               if (!DBA::isResult($r)) {
+                                                               $contact = DBA::selectFirst('contact', [], ['name' => $newname, 'uid' => $page_owner_uid]);
+                                                               if (!DBA::isResult($contact)) {
                                                                        //select someone by attag or nick and the name passed in
-                                                                       $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
-                                                                                       DBA::escape($name),
-                                                                                       DBA::escape($name),
-                                                                                       intval($page_owner_uid)
+                                                                       $contact = DBA::selectFirst('contact', [],
+                                                                               ['(`attag` = ? OR `nick` = ?) AND `uid` = ?', $name, $name, $page_owner_uid],
+                                                                               ['order' => ['attag' => true]]
                                                                        );
                                                                }
                                                        }
 
-                                                       if (DBA::isResult($r)) {
-                                                               $newname = $r[0]['name'];
-                                                               $profile = $r[0]['url'];
+                                                       if (DBA::isResult($contact)) {
+                                                               $newname = $contact['name'];
+                                                               $profile = $contact['url'];
 
-                                                               $notify = 'cid:' . $r[0]['id'];
+                                                               $notify = 'cid:' . $contact['id'];
                                                                if (strlen($inform)) {
                                                                        $inform .= ',';
                                                                }
@@ -562,8 +504,8 @@ function photos_post(App $a)
                                                }
 
                                                if ($profile) {
-                                                       if (substr($notify, 0, 4) === 'cid:') {
-                                                               $taginfo[] = [$newname, $profile, $notify, $r[0], '@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]'];
+                                                       if (!empty($contact)) {
+                                                               $taginfo[] = [$newname, $profile, $notify, $contact, '@[url=' . str_replace(',', '%2c', $profile) . ']' . $newname . '[/url]'];
                                                        } else {
                                                                $taginfo[] = [$newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'];
                                                        }
@@ -895,8 +837,10 @@ function photos_content(App $a)
        // photos/name/upload/xxxxx (xxxxx is album name)
        // photos/name/album/xxxxx
        // photos/name/album/xxxxx/edit
+       // photos/name/album/xxxxx/drop
        // photos/name/image/xxxxx
        // photos/name/image/xxxxx/edit
+       // photos/name/image/xxxxx/drop
 
        if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
                notice(L10n::t('Public access denied.') . EOL);
@@ -935,7 +879,8 @@ function photos_content(App $a)
        $contact        = null;
        $remote_contact = false;
        $contact_id     = 0;
-       $edit           = false;
+       $edit           = '';
+       $drop           = '';
 
        $owner_uid = $a->data['user']['uid'];
 
@@ -953,15 +898,12 @@ function photos_content(App $a)
                                        }
                                }
                        }
+
                        if ($contact_id) {
+                               $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
 
-                               $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
-                                       intval($contact_id),
-                                       intval($owner_uid)
-                               );
-                               if (DBA::isResult($r)) {
+                               if (DBA::isResult($contact)) {
                                        $can_post = true;
-                                       $contact = $r[0];
                                        $remote_contact = true;
                                        $visitor = $contact_id;
                                }
@@ -982,16 +924,13 @@ function photos_content(App $a)
                                }
                        }
                }
+
                if ($contact_id) {
                        $groups = Group::getIdsByContactId($contact_id);
-                       $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
-                               intval($contact_id),
-                               intval($owner_uid)
-                       );
-                       if (DBA::isResult($r)) {
-                               $contact = $r[0];
-                               $remote_contact = true;
-                       }
+
+                       $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
+
+                       $remote_contact = DBA::isResult($contact);
                }
        }
 
@@ -1120,6 +1059,24 @@ function photos_content(App $a)
                        $pager->getItemsPerPage()
                );
 
+               if ($cmd === 'drop') {
+                       $drop_url = $a->query_string;
+
+                       $extra_inputs = [
+                               ['name' => 'albumname', 'value' => $_POST['albumname']],
+                       ];
+
+                       return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
+                               '$method' => 'post',
+                               '$message' => L10n::t('Do you really want to delete this photo album and all its photos?'),
+                               '$extra_inputs' => $extra_inputs,
+                               '$confirm' => L10n::t('Delete Album'),
+                               '$confirm_url' => $drop_url,
+                               '$confirm_name' => 'dropalbum',
+                               '$cancel' => L10n::t('Cancel'),
+                       ]);
+               }
+
                // edit album name
                if ($cmd === 'edit') {
                        if (($album !== L10n::t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== L10n::t('Contact Photos'))) {
@@ -1141,6 +1098,7 @@ function photos_content(App $a)
                } else {
                        if (($album !== L10n::t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== L10n::t('Contact Photos')) && $can_post) {
                                $edit = [L10n::t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'];
+                               $drop = [L10n::t('Drop Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/drop'];
                        }
                }
 
@@ -1186,6 +1144,7 @@ function photos_content(App $a)
                        '$upload' => [L10n::t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)],
                        '$order' => $order,
                        '$edit' => $edit,
+                       '$drop' => $drop,
                        '$paginate' => $pager->renderFull($total),
                ]);
 
@@ -1203,12 +1162,7 @@ function photos_content(App $a)
                );
 
                if (!DBA::isResult($ph)) {
-                       $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
-                               LIMIT 1",
-                               intval($owner_uid),
-                               DBA::escape($datum)
-                       );
-                       if (DBA::isResult($ph)) {
+                       if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
                                notice(L10n::t('Permission denied. Access to this item may be restricted.'));
                        } else {
                                notice(L10n::t('Photo not available') . EOL);
@@ -1216,6 +1170,20 @@ function photos_content(App $a)
                        return;
                }
 
+               if ($cmd === 'drop') {
+                       $drop_url = $a->query_string;
+
+                       return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
+                               '$method' => 'post',
+                               '$message' => L10n::t('Do you really want to delete this photo?'),
+                               '$extra_inputs' => [],
+                               '$confirm' => L10n::t('Delete Photo'),
+                               '$confirm_url' => $drop_url,
+                               '$confirm_name' => 'delete',
+                               '$cancel' => L10n::t('Cancel'),
+                       ]);
+               }
+
                $prevlink = '';
                $nextlink = '';
 
@@ -1224,7 +1192,7 @@ function photos_content(App $a)
                 * The query leads to a really intense used index.
                 * By now we hide it if someone wants to.
                 */
-               if (!Config::get('system', 'no_count', false)) {
+               if ($cmd === 'view' && !Config::get('system', 'no_count', false)) {
                        $order_field = defaults($_GET, 'order', '');
 
                        if ($order_field === 'posted') {
@@ -1255,12 +1223,26 @@ function photos_content(App $a)
                                                break;
                                        }
                                }
-                               $edit_suffix = ((($cmd === 'edit') && $can_post) ? '/edit' : '');
+
                                if (!is_null($prv)) {
-                                       $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : '');
+                                       $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
                                }
                                if (!is_null($nxt)) {
-                                       $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : '');
+                                       $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
+                               }
+
+                               $tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
+                               $a->page['htmlhead'] .= Renderer::replaceMacros($tpl,[
+                                       '$prevlink' => $prevlink,
+                                       '$nextlink' => $nextlink
+                               ]);
+
+                               if ($prevlink) {
+                                       $prevlink = [$prevlink, '<div class="icon prev"></div>'];
+                               }
+
+                               if ($nextlink) {
+                                       $nextlink = [$nextlink, '<div class="icon next"></div>'];
                                }
                        }
                }
@@ -1282,33 +1264,23 @@ function photos_content(App $a)
                $album_link = 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
 
                $tools = null;
-               $lock = null;
 
                if ($can_post && ($ph[0]['uid'] == $owner_uid)) {
-                       $tools = [
-                               'edit'  => ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? L10n::t('View photo') : L10n::t('Edit photo'))],
-                               'profile'=>['profile_photo/use/'.$ph[0]['resource-id'], L10n::t('Use as profile photo')],
-                       ];
-
-                       // lock
-                       $lock = ((($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
-                                       || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])))
-                                       ? L10n::t('Private Message')
-                                       : Null);
-
-
-               }
-
-               if ($cmd === 'edit') {
-                       $tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
-                       $a->page['htmlhead'] .= Renderer::replaceMacros($tpl,[
-                               '$prevlink' => $prevlink,
-                               '$nextlink' => $nextlink
-                       ]);
-               }
+                       $tools = [];
+                       if ($cmd === 'edit') {
+                               $tools['view'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum, L10n::t('View photo')];
+                       } else {
+                               $tools['edit'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit', L10n::t('Edit photo')];
+                               $tools['delete'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/drop', L10n::t('Delete photo')];
+                               $tools['profile'] = ['profile_photo/use/'.$ph[0]['resource-id'], L10n::t('Use as profile photo')];
+                       }
 
-               if ($prevlink) {
-                       $prevlink = [$prevlink, '<div class="icon prev"></div>'];
+                       if (
+                               $ph[0]['uid'] == local_user()
+                               && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']))
+                       ) {
+                               $tools['lock'] = L10n::t('Private Photo');
+                       }
                }
 
                $photo = [
@@ -1321,11 +1293,6 @@ function photos_content(App $a)
                        'filename' => $hires['filename'],
                ];
 
-               if ($nextlink) {
-                       $nextlink = [$nextlink, '<div class="icon next"></div>'];
-               }
-
-
                // Do we have an item for this photo?
 
                // FIXME! - replace following code to display the conversation with our normal
@@ -1430,7 +1397,7 @@ function photos_content(App $a)
                        $tpl = Renderer::getMarkupTemplate('photo_item.tpl');
                        $return_path = $a->cmd;
 
-                       if ($can_post || Security::canWriteToUserWall($owner_uid)) {
+                       if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
                                $like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
                                $likebuttons = Renderer::replaceMacros($like_tpl, [
                                        '$id' => $link_item['id'],
@@ -1509,7 +1476,7 @@ function photos_content(App $a)
                                                continue;
                                        }
 
-                                       $profile_url = Contact::MagicLinkById($item['author-id']);
+                                       $profile_url = Contact::magicLinkbyId($item['author-id']);
                                        if (strpos($profile_url, 'redir/') === 0) {
                                                $sparkle = ' sparkle';
                                        } else {
@@ -1573,7 +1540,6 @@ function photos_content(App $a)
                        '$id' => $ph[0]['id'],
                        '$album' => [$album_link, $ph[0]['album']],
                        '$tools' => $tools,
-                       '$lock' => $lock,
                        '$photo' => $photo,
                        '$prevlink' => $prevlink,
                        '$nextlink' => $nextlink,
index bca2694d37360ebb9e7055114d91df6995eeca61..4b67dd6eb8e7930b6d217c7dc46024d55707956f 100644 (file)
@@ -19,39 +19,16 @@ function suggest_init(App $a)
        if (! local_user()) {
                return;
        }
+}
 
-       if (!empty($_GET['ignore'])) {
-               // Check if we should do HTML-based delete confirmation
-               if ($_REQUEST['confirm']) {
-                       // <form> can't take arguments in its "action" parameter
-                       // so add any arguments as hidden inputs
-                       $query = explode_querystring($a->query_string);
-                       $inputs = [];
-                       foreach ($query['args'] as $arg) {
-                               if (strpos($arg, 'confirm=') === false) {
-                                       $arg_parts = explode('=', $arg);
-                                       $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
-                               }
-                       }
-
-                       $a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
-                               '$method' => 'get',
-                               '$message' => L10n::t('Do you really want to delete this suggestion?'),
-                               '$extra_inputs' => $inputs,
-                               '$confirm' => L10n::t('Yes'),
-                               '$confirm_url' => $query['base'],
-                               '$confirm_name' => 'confirmed',
-                               '$cancel' => L10n::t('Cancel'),
-                       ]);
-                       $a->error = 1; // Set $a->error so the other module functions don't execute
-                       return;
-               }
-               // Now check how the user responded to the confirmation query
-               if (!$_REQUEST['canceled']) {
-                       DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]);
-               }
+function suggest_post(App $a)
+{
+       if (!empty($_POST['ignore']) && !empty($_POST['confirm'])) {
+               DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_POST['ignore']]);
+               notice(L10n::t('Contact suggestion successfully ignored.'));
        }
 
+       $a->internalRedirect('suggest');
 }
 
 function suggest_content(App $a)
@@ -76,11 +53,34 @@ function suggest_content(App $a)
                return $o;
        }
 
+
+       if (!empty($_GET['ignore'])) {
+               // <form> can't take arguments in its "action" parameter
+               // so add any arguments as hidden inputs
+               $query = explode_querystring($a->query_string);
+               $inputs = [];
+               foreach ($query['args'] as $arg) {
+                       if (strpos($arg, 'confirm=') === false) {
+                               $arg_parts = explode('=', $arg);
+                               $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
+                       }
+               }
+
+               return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
+                       '$method' => 'post',
+                       '$message' => L10n::t('Do you really want to delete this suggestion?'),
+                       '$extra_inputs' => $inputs,
+                       '$confirm' => L10n::t('Yes'),
+                       '$confirm_url' => $query['base'],
+                       '$confirm_name' => 'confirm',
+                       '$cancel' => L10n::t('Cancel'),
+               ]);
+       }
+
        $id = 0;
        $entries = [];
 
        foreach ($r as $rr) {
-
                $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
                $ignlnk = System::baseUrl() . '/suggest?ignore=' . $rr['id'];
                $photo_menu = [
index f45817c4e9f010577d6f1cc0c38d24ad9f508f2b..728a71bb5d70495bd6810c2a143e77f71294b78d 100644 (file)
@@ -82,33 +82,6 @@ function videos_post(App $a)
        }
 
        if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
-               // Check if we should do HTML-based delete confirmation
-               if (empty($_REQUEST['confirm'])) {
-                       if (!empty($_REQUEST['canceled'])) {
-                               $a->internalRedirect('videos/' . $a->data['user']['nickname']);
-                       }
-
-                       $drop_url = $a->query_string;
-
-                       $a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
-                               '$method' => 'post',
-                               '$message' => L10n::t('Do you really want to delete this video?'),
-                               '$extra_inputs' => [
-                                       ['name' => 'id'    , 'value' => $_POST['id']],
-                                       ['name' => 'delete', 'value' => 'x']
-                               ],
-                               '$confirm' => L10n::t('Delete Video'),
-                               '$confirm_url' => $drop_url,
-                               '$confirm_name' => 'confirm', // Needed so that confirmation will bring us back into this if statement
-                               '$cancel' => L10n::t('Cancel'),
-
-                       ]);
-
-                       $a->error = 1; // Set $a->error so the other module functions don't execute
-
-                       return;
-               }
-
                $video_id = $_POST['id'];
 
                if (Attach::exists(['id' => $video_id, 'uid' => local_user()])) {
index f05996d2fbcf22ef9fb59724248548a4c370bcd6..939c73a142e21bb509240639c212a8244526bb14 100644 (file)
@@ -18,7 +18,6 @@ function viewsrc_content(App $a)
        $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
 
        if (!$item_id) {
-               $a->error = 404;
                notice(L10n::t('Item not found.') . EOL);
                return;
        }
index 70089a76781d8fd08ae79e98857f79d54803c44e..477e44bf1df2ef011ff5f61047f051e6edbd5f99 100644 (file)
@@ -49,7 +49,6 @@ class App
        public $page_contact;
        public $content;
        public $data = [];
-       public $error = false;
        public $cmd = '';
        public $argv;
        public $argc;
@@ -1248,9 +1247,7 @@ class App
 
                        // "rawContent" is especially meant for technical endpoints.
                        // This endpoint doesn't need any theme initialization or other comparable stuff.
-                       if (!$this->error) {
                                call_user_func([$this->module_class, 'rawContent']);
-                       }
                }
 
                // Load current theme info after module has been initialized as theme could have been set in module
@@ -1265,24 +1262,20 @@ class App
                }
 
                if ($this->module_class) {
-                       if (! $this->error && $_SERVER['REQUEST_METHOD'] === 'POST') {
+                       if ($_SERVER['REQUEST_METHOD'] === 'POST') {
                                Core\Hook::callAll($this->module . '_mod_post', $_POST);
                                call_user_func([$this->module_class, 'post']);
                        }
 
-                       if (! $this->error) {
                                Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder);
                                call_user_func([$this->module_class, 'afterpost']);
-                       }
 
-                       if (! $this->error) {
                                $arr = ['content' => $content];
                                Core\Hook::callAll($this->module . '_mod_content', $arr);
                                $content = $arr['content'];
                                $arr = ['content' => call_user_func([$this->module_class, 'content'])];
                                Core\Hook::callAll($this->module . '_mod_aftercontent', $arr);
                                $content .= $arr['content'];
-                       }
                }
 
                // initialise content region
index fb87bc52157a066cff8a835898d82bcd65c128f0..969c1f664249a84c191dee0143e023341e1febc3 100644 (file)
@@ -113,7 +113,6 @@ class Profile
                if (!DBA::isResult($user) && empty($profiledata)) {
                        Logger::log('profile error: ' . $a->query_string, Logger::DEBUG);
                        notice(L10n::t('Requested account is not available.') . EOL);
-                       $a->error = 404;
                        return;
                }
 
@@ -131,7 +130,6 @@ class Profile
                if (empty($pdata) && empty($profiledata)) {
                        Logger::log('profile error: ' . $a->query_string, Logger::DEBUG);
                        notice(L10n::t('Requested profile is not available.') . EOL);
-                       $a->error = 404;
                        return;
                }
 
index 72aedd8b70aa02afc9a0f5e588a6eaa1401ea2e8..b6f24ec3b292ac182e618274dbe7b899dbc68e8d 100644 (file)
@@ -9,7 +9,6 @@
 <div id="photo-album-edit-name-end"></div>
 
 <input id="photo-album-edit-submit" type="submit" name="submit" value="{{$submit}}" />
-<input id="photo-album-edit-drop" type="submit" name="dropalbum" value="{{$dropsubmit}}" onclick="return confirmDelete();" />
 
 </form>
 </div>
index cae3b868af01e6abd553a23e02ad723d70ff663e..5080663abd1bc374f88692fde7da82bde0714d70 100644 (file)
@@ -3,6 +3,12 @@
 {{if $edit}}
 <div id="album-edit-link"><a href="{{$edit.1}}" title="{{$edit.0}}">{{$edit.0}}</a></div>
 {{/if}}
+{{if $edit}}
+<div id="album-edit-link"><a href="{{$edit.1}}" title="{{$edit.0}}">{{$edit.0}}</a></div>
+{{/if}}
+{{if $drop}}
+<div id="album-drop-link"><a href="{{$drop.1}}" title="{{$drop.0}}">{{$drop.0}}</a></div>
+{{/if}}
 <div class="photos-upload-link" ><a href="{{$order.1}}" title="{{$order.0}}">{{$order.0}}</a></div>
 {{if $can_post}}
 <div class="photos-upload-link" ><a href="{{$upload.1}}">{{$upload.0}}</a></div>
index 8b22dfb44cd682756b382c891dbf6e9017ace0c1..49a550e42b310b89f8ac4e5fbd9dbd2ce14bdcfa 100644 (file)
@@ -1,6 +1,5 @@
 
-
-<form action="photos/{{$nickname}}/{{$resource_id}}" method="post" id="photo_edit_form" >
+<form action="photos/{{$nickname}}/image/{{$resource_id}}/edit" method="post" id="photo_edit_form" >
 
        <input type="hidden" name="item_id" value="{{$item_id}}" />
        <input type="hidden" name="origaname" value="{{$album.2}}" />
@@ -28,9 +27,6 @@
        <div id="photo-edit-perms-end"></div>
 
        <input id="photo-edit-submit-button" type="submit" name="submit" value="{{$submit}}" />
-       <input id="photo-edit-delete-button" type="submit" name="delete" value="{{$delete}}" onclick="return confirmDelete();" />
 
        <div id="photo-edit-end"></div>
 </form>
-
-
index 372bcb536ede123b32c3d7d7f3ad88d44dabeff7..7170ceb333a054db29d79897879e66e1601a4377 100644 (file)
@@ -4,11 +4,22 @@
 
 <div id="photo-edit-link-wrap">
 {{if $tools}}
-<a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
-|
-<a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+       {{if $tools.view}}
+               <a id="photo-view-link" href="{{$tools.view.0}}">{{$tools.view.1}}</a>
+       {{/if}}
+       {{if $tools.edit}}
+               <a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
+       {{/if}}
+       {{if $tools.delete}}
+               | <a id="photo-edit-link" href="{{$tools.delete.0}}">{{$tools.delete.1}}</a>
+       {{/if}}
+       {{if $tools.profile}}
+               | <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+       {{/if}}
+       {{if $tools.lock}}
+               | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event,'photo/{{$id}}');" />
+       {{/if}}
 {{/if}}
-{{if $lock}} | <img src="images/lock_icon.gif" class="lockview" alt="{{$lock}}" onclick="lockview(event,'photo/{{$id}}');" /> {{/if}}
 </div>
 
 {{if $prevlink}}<div id="photo-prev-link"><a href="{{$prevlink.0}}">{{$prevlink.1 nofilter}}</a></div>{{/if}}
index 77173385b192ddf27bd6f555c934a126a6348dab..2e7160aafa9217b00f323911030c03da1e0c83ad 100644 (file)
@@ -23,6 +23,15 @@ $(document).ready(function() {
                        addToModal(modalUrl, 'photo-album-edit-wrapper');
                }
        });
+
+       // Click event listener for the album drop link/button.
+       $("body").on('click', '#album-drop-link', function() {
+               var modalUrl = $(this).attr("data-modal-url");
+
+               if (typeof modalUrl !== "undefined") {
+                       addToModal(modalUrl);
+               }
+       });
 });
 
 $(window).load(function() {
index 0b58d520d8b305f333a18cbd3bab072b69911dfe..4f240922a792ddaab9fbb611312e8260e6d262b0 100644 (file)
@@ -7,7 +7,6 @@
 
                <div class="pull-right">
                        <input class="btn-primary btn btn-small" id="photo-album-edit-submit" type="submit" name="submit" value="{{$submit}}" />
-                       <input class="btn-primary btn btn-small" id="photo-album-edit-drop" type="submit" name="dropalbum" value="{{$dropsubmit}}" onclick="return confirmDelete();" />
                </div>
        </form>
        <div class="clear"></div>
index 62611593c80dcc4fd1cb522e85dd3e5cdbd21813..36072a56b1b6227cd18dd394e43a6ff21ccc1876 100644 (file)
@@ -1,6 +1,5 @@
 
-<form action="{{$confirm_url}}" id="confirm-form" method="{{$method}}">
-
+<form action="{{$confirm_url}}" id="confirm-form" method="{{$method}}" class="generic-page-wrapper">
        <div id="confirm-message">{{$message}}</div>
        {{foreach $extra_inputs as $input}}
        <input type="hidden" name="{{$input.name}}" value="{{$input.value}}" />
@@ -10,5 +9,4 @@
                <button type="submit" name="{{$confirm_name}}" id="confirm-submit-button" class="btn btn-primary confirm-button" value="{{$confirm}}">{{$confirm}}</button>
                <button type="submit" name="canceled" id="confirm-cancel-button" class="btn confirm-button" data-dismiss="modal">{{$cancel}}</button>
        </div>
-
 </form>
index a34e8ea8616483c0e4683c90642e9aa5e415881c..a3b030477a17ce59c74d867d4d3033b736e24d1f 100644 (file)
                        <i class="fa fa-pencil"></i>
                </button>
                {{/if}}
+               {{if $drop}}
+               <span class="icon-padding"> </span>
+               <button id="album-drop-link" class="btn-link page-action faded-icon" type="button" data-modal-url="{{$drop.1}}" title="{{$drop.0}}" data-toggle="tooltip">
+                       <i class="fa fa-trash"></i>
+               </button>
+               {{/if}}
 
                {{if ! $noorder}}
                <span class="icon-padding"> </span>
index 359c42669622c9f334451048c163f9c3f8c41717..82bddcfc61c2870596fbefe523ef2377ccac7460 100644 (file)
                </a>
        </div>
        <div class="pull-right" id="photo-edit-link-wrap">
-               {{if $tools}}
+{{if $tools}}
+       {{if $tools.view}}
+               <span class="icon-padding"> </span>
+               <a id="photo-edit-link" href="{{$tools.view.0}}" title="{{$tools.view.1}}" data-toggle="tooltip">
+                       <i class="page-action faded-icon fa fa-image"></i>
+               </a>
+       {{/if}}
+       {{if $tools.edit}}
                <span class="icon-padding"> </span>
                <a id="photo-edit-link" href="{{$tools.edit.0}}" title="{{$tools.edit.1}}" data-toggle="tooltip">
                        <i class="page-action faded-icon fa fa-pencil"></i>
                </a>
+       {{/if}}
+       {{if $tools.delete}}
+               <span class="icon-padding"> </span>
+               <a id="photo-edit-link" href="{{$tools.delete.0}}" title="{{$tools.delete.1}}" data-toggle="tooltip">
+                       <i class="page-action faded-icon fa fa-trash"></i>
+               </a>
+       {{/if}}
+       {{if $tools.profile}}
                <span class="icon-padding"> </span>
                <a id="photo-toprofile-link" href="{{$tools.profile.0}}" title="{{$tools.profile.1}}" data-toggle="tooltip">
                        <i class="page-action faded-icon fa fa-user"></i>
                </a>
-               {{/if}}
-               {{if $lock}}
+       {{/if}}
+       {{if $tools.lock}}
                <span class="icon-padding"> </span>
-               <a id="photo-lock-link" onclick="lockview(event,'photo/{{$id}}');" title="{{$lock}}" data-toggle="tooltip">
+               <a id="photo-lock-link" onclick="lockview(event,'photo/{{$id}}');" title="{{$tools.lock}}" data-toggle="tooltip">
                        <i class="page-action faded-icon fa fa-lock"></i>
                </a>
-               {{/if}}
+       {{/if}}
+{{/if}}
        </div>
        <div class="clear"></div>
 
                <hr>
        </div>
 
+{{if !$edit}}
        {{* Insert the comments *}}
        <div id="photo-comment-wrapper-{{$id}}" class="photo-comment-wrapper">
                {{$comments nofilter}}
        </div>
 
        {{$paginate nofilter}}
+{{/if}}
 </div>
index a4787270fe4e18fb29ec3a448c7e3201c7ed8efc..1ce336b0a61b22bbac4c746cb5451cf72e4790a0 100644 (file)
@@ -3,11 +3,22 @@
 
 <div id="photo-edit-link-wrap">
 {{if $tools}}
-<a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
-|
-<a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+    {{if $tools.view}}
+        <a id="photo-view-link" href="{{$tools.view.0}}">{{$tools.view.1}}</a>
+    {{/if}}
+    {{if $tools.edit}}
+        <a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
+    {{/if}}
+    {{if $tools.delete}}
+        | <a id="photo-edit-link" href="{{$tools.delete.0}}">{{$tools.delete.1}}</a>
+    {{/if}}
+    {{if $tools.profile}}
+        | <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+    {{/if}}
+    {{if $tools.lock}}
+        | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event,'photo/{{$id}}');" />
+    {{/if}}
 {{/if}}
-{{if $lock}} | <img src="images/lock_icon.gif" class="lockview" alt="{{$lock}}" onclick="lockview(event,'photo/{{$id}}');" /> {{/if}}
 </div>
 
 <div id="photo-photo"><a href="{{$photo.href}}" title="{{$photo.title}}"><img src="{{$photo.src}}" /></a></div>
index 617bcc5b25341b8a3ab85bbd67f4165981d6ddcb..f70ec5b561ed40bc5ad93b96cc3084f50c1e5f32 100644 (file)
@@ -4,11 +4,22 @@
 
 <div id="photo-edit-link-wrap">
 {{if $tools}}
-<a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
-|
-<a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+       {{if $tools.view}}
+               <a id="photo-view-link" href="{{$tools.view.0}}">{{$tools.view.1}}</a>
+       {{/if}}
+       {{if $tools.edit}}
+               <a id="photo-edit-link" href="{{$tools.edit.0}}">{{$tools.edit.1}}</a>
+       {{/if}}
+       {{if $tools.delete}}
+               | <a id="photo-edit-link" href="{{$tools.delete.0}}">{{$tools.delete.1}}</a>
+       {{/if}}
+       {{if $tools.profile}}
+               | <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
+       {{/if}}
+       {{if $tools.lock}}
+               | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event,'photo/{{$id}}');" />
+       {{/if}}
 {{/if}}
-{{if $lock}} | <img src="images/lock_icon.gif" class="lockview" alt="{{$lock}}" onclick="lockview(event,'photo/{{$id}}');" /> {{/if}}
 </div>
 
 {{if $prevlink}}<div id="photo-prev-link"><a href="{{$prevlink.0}}">{{$prevlink.1 nofilter}}</a></div>{{/if}}